Skip to content

Commit 40ff5f5

Browse files
committed
fixes #244
1 parent 80c0551 commit 40ff5f5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

python_coreml_stable_diffusion/controlnet.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def __init__(
6969
norm_num_groups=32,
7070
norm_eps=1e-5,
7171
cross_attention_dim=1280,
72+
transformer_layers_per_block=1,
7273
attention_head_dim=8,
7374
use_linear_projection=False,
7475
upcast_attention=False,
@@ -129,6 +130,9 @@ def __init__(
129130
if isinstance(attention_head_dim, int):
130131
attention_head_dim = (attention_head_dim,) * len(down_block_types)
131132

133+
if isinstance(transformer_layers_per_block, int):
134+
transformer_layers_per_block = [transformer_layers_per_block] * len(down_block_types)
135+
132136
# down
133137
output_channel = block_out_channels[0]
134138

@@ -142,6 +146,7 @@ def __init__(
142146

143147
down_block = get_down_block(
144148
down_block_type,
149+
transformer_layers_per_block=transformer_layers_per_block[i],
145150
num_layers=layers_per_block,
146151
in_channels=input_channel,
147152
out_channels=output_channel,
@@ -151,6 +156,7 @@ def __init__(
151156
cross_attention_dim=cross_attention_dim,
152157
attn_num_head_channels=attention_head_dim[i],
153158
downsample_padding=downsample_padding,
159+
add_downsample=not is_final_block,
154160
)
155161
self.down_blocks.append(down_block)
156162

0 commit comments

Comments
 (0)