Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
cfc99adf
Unverified
Commit
cfc99adf
authored
Apr 16, 2023
by
Patrick von Platen
Committed by
GitHub
Apr 16, 2023
Browse files
Add global pooling to controlnet (#3121)
parent
807f69b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
0 deletions
+7
-0
src/diffusers/models/controlnet.py
src/diffusers/models/controlnet.py
+7
-0
No files found.
src/diffusers/models/controlnet.py
View file @
cfc99adf
...
@@ -119,6 +119,7 @@ class ControlNetModel(ModelMixin, ConfigMixin):
...
@@ -119,6 +119,7 @@ class ControlNetModel(ModelMixin, ConfigMixin):
projection_class_embeddings_input_dim
:
Optional
[
int
]
=
None
,
projection_class_embeddings_input_dim
:
Optional
[
int
]
=
None
,
controlnet_conditioning_channel_order
:
str
=
"rgb"
,
controlnet_conditioning_channel_order
:
str
=
"rgb"
,
conditioning_embedding_out_channels
:
Optional
[
Tuple
[
int
]]
=
(
16
,
32
,
96
,
256
),
conditioning_embedding_out_channels
:
Optional
[
Tuple
[
int
]]
=
(
16
,
32
,
96
,
256
),
global_pool_conditions
:
bool
=
False
,
):
):
super
().
__init__
()
super
().
__init__
()
...
@@ -566,6 +567,12 @@ class ControlNetModel(ModelMixin, ConfigMixin):
...
@@ -566,6 +567,12 @@ class ControlNetModel(ModelMixin, ConfigMixin):
down_block_res_samples
=
[
sample
*
conditioning_scale
for
sample
in
down_block_res_samples
]
down_block_res_samples
=
[
sample
*
conditioning_scale
for
sample
in
down_block_res_samples
]
mid_block_res_sample
*=
conditioning_scale
mid_block_res_sample
*=
conditioning_scale
if
self
.
config
.
global_pool_conditions
:
down_block_res_samples
=
[
torch
.
mean
(
sample
,
dim
=
(
2
,
3
),
keepdim
=
True
)
for
sample
in
down_block_res_samples
]
mid_block_res_sample
=
torch
.
mean
(
mid_block_res_sample
,
dim
=
(
2
,
3
),
keepdim
=
True
)
if
not
return_dict
:
if
not
return_dict
:
return
(
down_block_res_samples
,
mid_block_res_sample
)
return
(
down_block_res_samples
,
mid_block_res_sample
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment