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
chenpangpang
ComfyUI
Commits
10860bcd
Commit
10860bcd
authored
Mar 05, 2024
by
comfyanonymous
Browse files
Add compression_ratio to controlnet code.
parent
a38b9b3a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
comfy/controlnet.py
comfy/controlnet.py
+5
-4
No files found.
comfy/controlnet.py
View file @
10860bcd
...
@@ -37,6 +37,7 @@ class ControlBase:
...
@@ -37,6 +37,7 @@ class ControlBase:
self
.
timestep_percent_range
=
(
0.0
,
1.0
)
self
.
timestep_percent_range
=
(
0.0
,
1.0
)
self
.
global_average_pooling
=
False
self
.
global_average_pooling
=
False
self
.
timestep_range
=
None
self
.
timestep_range
=
None
self
.
compression_ratio
=
8
if
device
is
None
:
if
device
is
None
:
device
=
comfy
.
model_management
.
get_torch_device
()
device
=
comfy
.
model_management
.
get_torch_device
()
...
@@ -158,11 +159,11 @@ class ControlNet(ControlBase):
...
@@ -158,11 +159,11 @@ class ControlNet(ControlBase):
dtype
=
self
.
manual_cast_dtype
dtype
=
self
.
manual_cast_dtype
output_dtype
=
x_noisy
.
dtype
output_dtype
=
x_noisy
.
dtype
if
self
.
cond_hint
is
None
or
x_noisy
.
shape
[
2
]
*
8
!=
self
.
cond_hint
.
shape
[
2
]
or
x_noisy
.
shape
[
3
]
*
8
!=
self
.
cond_hint
.
shape
[
3
]:
if
self
.
cond_hint
is
None
or
x_noisy
.
shape
[
2
]
*
self
.
compression_ratio
!=
self
.
cond_hint
.
shape
[
2
]
or
x_noisy
.
shape
[
3
]
*
self
.
compression_ratio
!=
self
.
cond_hint
.
shape
[
3
]:
if
self
.
cond_hint
is
not
None
:
if
self
.
cond_hint
is
not
None
:
del
self
.
cond_hint
del
self
.
cond_hint
self
.
cond_hint
=
None
self
.
cond_hint
=
None
self
.
cond_hint
=
comfy
.
utils
.
common_upscale
(
self
.
cond_hint_original
,
x_noisy
.
shape
[
3
]
*
8
,
x_noisy
.
shape
[
2
]
*
8
,
'nearest-exact'
,
"center"
).
to
(
dtype
).
to
(
self
.
device
)
self
.
cond_hint
=
comfy
.
utils
.
common_upscale
(
self
.
cond_hint_original
,
x_noisy
.
shape
[
3
]
*
self
.
compression_ratio
,
x_noisy
.
shape
[
2
]
*
self
.
compression_ratio
,
'nearest-exact'
,
"center"
).
to
(
dtype
).
to
(
self
.
device
)
if
x_noisy
.
shape
[
0
]
!=
self
.
cond_hint
.
shape
[
0
]:
if
x_noisy
.
shape
[
0
]
!=
self
.
cond_hint
.
shape
[
0
]:
self
.
cond_hint
=
broadcast_image_to
(
self
.
cond_hint
,
x_noisy
.
shape
[
0
],
batched_number
)
self
.
cond_hint
=
broadcast_image_to
(
self
.
cond_hint
,
x_noisy
.
shape
[
0
],
batched_number
)
...
@@ -456,12 +457,12 @@ class T2IAdapter(ControlBase):
...
@@ -456,12 +457,12 @@ class T2IAdapter(ControlBase):
else
:
else
:
return
None
return
None
if
self
.
cond_hint
is
None
or
x_noisy
.
shape
[
2
]
*
8
!=
self
.
cond_hint
.
shape
[
2
]
or
x_noisy
.
shape
[
3
]
*
8
!=
self
.
cond_hint
.
shape
[
3
]:
if
self
.
cond_hint
is
None
or
x_noisy
.
shape
[
2
]
*
self
.
compression_ratio
!=
self
.
cond_hint
.
shape
[
2
]
or
x_noisy
.
shape
[
3
]
*
self
.
compression_ratio
!=
self
.
cond_hint
.
shape
[
3
]:
if
self
.
cond_hint
is
not
None
:
if
self
.
cond_hint
is
not
None
:
del
self
.
cond_hint
del
self
.
cond_hint
self
.
control_input
=
None
self
.
control_input
=
None
self
.
cond_hint
=
None
self
.
cond_hint
=
None
width
,
height
=
self
.
scale_image_to
(
x_noisy
.
shape
[
3
]
*
8
,
x_noisy
.
shape
[
2
]
*
8
)
width
,
height
=
self
.
scale_image_to
(
x_noisy
.
shape
[
3
]
*
self
.
compression_ratio
,
x_noisy
.
shape
[
2
]
*
self
.
compression_ratio
)
self
.
cond_hint
=
comfy
.
utils
.
common_upscale
(
self
.
cond_hint_original
,
width
,
height
,
'nearest-exact'
,
"center"
).
float
().
to
(
self
.
device
)
self
.
cond_hint
=
comfy
.
utils
.
common_upscale
(
self
.
cond_hint_original
,
width
,
height
,
'nearest-exact'
,
"center"
).
float
().
to
(
self
.
device
)
if
self
.
channels_in
==
1
and
self
.
cond_hint
.
shape
[
1
]
>
1
:
if
self
.
channels_in
==
1
and
self
.
cond_hint
.
shape
[
1
]
>
1
:
self
.
cond_hint
=
torch
.
mean
(
self
.
cond_hint
,
1
,
keepdim
=
True
)
self
.
cond_hint
=
torch
.
mean
(
self
.
cond_hint
,
1
,
keepdim
=
True
)
...
...
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