Skip to content

Commit 5c90465

Browse files
authored
Merge branch 'main' into bugfix/textual-inversion
2 parents 3546c41 + c04099a commit 5c90465

4 files changed

Lines changed: 172 additions & 1 deletion

File tree

invokeai/backend/install/model_install_backend.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,12 @@ def _make_attributes(self, path: Path, info: ModelProbeInfo) -> dict:
460460
possible_conf = path.with_suffix(".yaml")
461461
if possible_conf.exists():
462462
legacy_conf = str(self.relative_to_root(possible_conf))
463+
else:
464+
legacy_conf = Path(
465+
self.config.root_path,
466+
"configs/controlnet",
467+
("cldm_v15.yaml" if info.base_type == BaseModelType("sd-1") else "cldm_v21.yaml"),
468+
)
463469

464470
if legacy_conf:
465471
attributes.update(dict(config=str(legacy_conf)))

invokeai/backend/model_management/models/controlnet.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,14 @@ def _convert_controlnet_ckpt_and_cache(
132132
model_path: str,
133133
output_path: str,
134134
base_model: BaseModelType,
135-
model_config: ControlNetModel.CheckpointConfig,
135+
model_config: str,
136136
) -> str:
137137
"""
138138
Convert the controlnet from checkpoint format to diffusers format,
139139
cache it to disk, and return Path to converted
140140
file. If already on disk then just returns Path.
141141
"""
142+
print(f"DEBUG: controlnet config = {model_config}")
142143
app_config = InvokeAIAppConfig.get_config()
143144
weights = app_config.root_path / model_path
144145
output_path = Path(output_path)
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
model:
2+
target: cldm.cldm.ControlLDM
3+
params:
4+
linear_start: 0.00085
5+
linear_end: 0.0120
6+
num_timesteps_cond: 1
7+
log_every_t: 200
8+
timesteps: 1000
9+
first_stage_key: "jpg"
10+
cond_stage_key: "txt"
11+
control_key: "hint"
12+
image_size: 64
13+
channels: 4
14+
cond_stage_trainable: false
15+
conditioning_key: crossattn
16+
monitor: val/loss_simple_ema
17+
scale_factor: 0.18215
18+
use_ema: False
19+
only_mid_control: False
20+
21+
control_stage_config:
22+
target: cldm.cldm.ControlNet
23+
params:
24+
image_size: 32 # unused
25+
in_channels: 4
26+
hint_channels: 3
27+
model_channels: 320
28+
attention_resolutions: [ 4, 2, 1 ]
29+
num_res_blocks: 2
30+
channel_mult: [ 1, 2, 4, 4 ]
31+
num_heads: 8
32+
use_spatial_transformer: True
33+
transformer_depth: 1
34+
context_dim: 768
35+
use_checkpoint: True
36+
legacy: False
37+
38+
unet_config:
39+
target: cldm.cldm.ControlledUnetModel
40+
params:
41+
image_size: 32 # unused
42+
in_channels: 4
43+
out_channels: 4
44+
model_channels: 320
45+
attention_resolutions: [ 4, 2, 1 ]
46+
num_res_blocks: 2
47+
channel_mult: [ 1, 2, 4, 4 ]
48+
num_heads: 8
49+
use_spatial_transformer: True
50+
transformer_depth: 1
51+
context_dim: 768
52+
use_checkpoint: True
53+
legacy: False
54+
55+
first_stage_config:
56+
target: ldm.models.autoencoder.AutoencoderKL
57+
params:
58+
embed_dim: 4
59+
monitor: val/rec_loss
60+
ddconfig:
61+
double_z: true
62+
z_channels: 4
63+
resolution: 256
64+
in_channels: 3
65+
out_ch: 3
66+
ch: 128
67+
ch_mult:
68+
- 1
69+
- 2
70+
- 4
71+
- 4
72+
num_res_blocks: 2
73+
attn_resolutions: []
74+
dropout: 0.0
75+
lossconfig:
76+
target: torch.nn.Identity
77+
78+
cond_stage_config:
79+
target: ldm.modules.encoders.modules.FrozenCLIPEmbedder
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
model:
2+
target: cldm.cldm.ControlLDM
3+
params:
4+
linear_start: 0.00085
5+
linear_end: 0.0120
6+
num_timesteps_cond: 1
7+
log_every_t: 200
8+
timesteps: 1000
9+
first_stage_key: "jpg"
10+
cond_stage_key: "txt"
11+
control_key: "hint"
12+
image_size: 64
13+
channels: 4
14+
cond_stage_trainable: false
15+
conditioning_key: crossattn
16+
monitor: val/loss_simple_ema
17+
scale_factor: 0.18215
18+
use_ema: False
19+
only_mid_control: False
20+
21+
control_stage_config:
22+
target: cldm.cldm.ControlNet
23+
params:
24+
use_checkpoint: True
25+
image_size: 32 # unused
26+
in_channels: 4
27+
hint_channels: 3
28+
model_channels: 320
29+
attention_resolutions: [ 4, 2, 1 ]
30+
num_res_blocks: 2
31+
channel_mult: [ 1, 2, 4, 4 ]
32+
num_head_channels: 64 # need to fix for flash-attn
33+
use_spatial_transformer: True
34+
use_linear_in_transformer: True
35+
transformer_depth: 1
36+
context_dim: 1024
37+
legacy: False
38+
39+
unet_config:
40+
target: cldm.cldm.ControlledUnetModel
41+
params:
42+
use_checkpoint: True
43+
image_size: 32 # unused
44+
in_channels: 4
45+
out_channels: 4
46+
model_channels: 320
47+
attention_resolutions: [ 4, 2, 1 ]
48+
num_res_blocks: 2
49+
channel_mult: [ 1, 2, 4, 4 ]
50+
num_head_channels: 64 # need to fix for flash-attn
51+
use_spatial_transformer: True
52+
use_linear_in_transformer: True
53+
transformer_depth: 1
54+
context_dim: 1024
55+
legacy: False
56+
57+
first_stage_config:
58+
target: ldm.models.autoencoder.AutoencoderKL
59+
params:
60+
embed_dim: 4
61+
monitor: val/rec_loss
62+
ddconfig:
63+
#attn_type: "vanilla-xformers"
64+
double_z: true
65+
z_channels: 4
66+
resolution: 256
67+
in_channels: 3
68+
out_ch: 3
69+
ch: 128
70+
ch_mult:
71+
- 1
72+
- 2
73+
- 4
74+
- 4
75+
num_res_blocks: 2
76+
attn_resolutions: []
77+
dropout: 0.0
78+
lossconfig:
79+
target: torch.nn.Identity
80+
81+
cond_stage_config:
82+
target: ldm.modules.encoders.modules.FrozenOpenCLIPEmbedder
83+
params:
84+
freeze: True
85+
layer: "penultimate"

0 commit comments

Comments
 (0)