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
0a030098
Commit
0a030098
authored
Apr 06, 2024
by
comfyanonymous
Browse files
Fix issue with controlnet models getting loaded multiple times.
parent
de172f8b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
comfy/controlnet.py
comfy/controlnet.py
+7
-3
comfy/model_management.py
comfy/model_management.py
+2
-0
No files found.
comfy/controlnet.py
View file @
0a030098
...
@@ -138,11 +138,13 @@ class ControlBase:
...
@@ -138,11 +138,13 @@ class ControlBase:
return
out
return
out
class
ControlNet
(
ControlBase
):
class
ControlNet
(
ControlBase
):
def
__init__
(
self
,
control_model
,
global_average_pooling
=
False
,
device
=
None
,
load_device
=
None
,
manual_cast_dtype
=
None
):
def
__init__
(
self
,
control_model
=
None
,
global_average_pooling
=
False
,
device
=
None
,
load_device
=
None
,
manual_cast_dtype
=
None
):
super
().
__init__
(
device
)
super
().
__init__
(
device
)
self
.
control_model
=
control_model
self
.
control_model
=
control_model
self
.
load_device
=
load_device
self
.
load_device
=
load_device
if
control_model
is
not
None
:
self
.
control_model_wrapped
=
comfy
.
model_patcher
.
ModelPatcher
(
self
.
control_model
,
load_device
=
load_device
,
offload_device
=
comfy
.
model_management
.
unet_offload_device
())
self
.
control_model_wrapped
=
comfy
.
model_patcher
.
ModelPatcher
(
self
.
control_model
,
load_device
=
load_device
,
offload_device
=
comfy
.
model_management
.
unet_offload_device
())
self
.
global_average_pooling
=
global_average_pooling
self
.
global_average_pooling
=
global_average_pooling
self
.
model_sampling_current
=
None
self
.
model_sampling_current
=
None
self
.
manual_cast_dtype
=
manual_cast_dtype
self
.
manual_cast_dtype
=
manual_cast_dtype
...
@@ -183,7 +185,9 @@ class ControlNet(ControlBase):
...
@@ -183,7 +185,9 @@ class ControlNet(ControlBase):
return
self
.
control_merge
(
None
,
control
,
control_prev
,
output_dtype
)
return
self
.
control_merge
(
None
,
control
,
control_prev
,
output_dtype
)
def
copy
(
self
):
def
copy
(
self
):
c
=
ControlNet
(
self
.
control_model
,
global_average_pooling
=
self
.
global_average_pooling
,
load_device
=
self
.
load_device
,
manual_cast_dtype
=
self
.
manual_cast_dtype
)
c
=
ControlNet
(
None
,
global_average_pooling
=
self
.
global_average_pooling
,
load_device
=
self
.
load_device
,
manual_cast_dtype
=
self
.
manual_cast_dtype
)
c
.
control_model
=
self
.
control_model
c
.
control_model_wrapped
=
self
.
control_model_wrapped
self
.
copy_to
(
c
)
self
.
copy_to
(
c
)
return
c
return
c
...
...
comfy/model_management.py
View file @
0a030098
...
@@ -385,6 +385,8 @@ def load_models_gpu(models, memory_required=0):
...
@@ -385,6 +385,8 @@ def load_models_gpu(models, memory_required=0):
inference_memory
=
minimum_inference_memory
()
inference_memory
=
minimum_inference_memory
()
extra_mem
=
max
(
inference_memory
,
memory_required
)
extra_mem
=
max
(
inference_memory
,
memory_required
)
models
=
set
(
models
)
models_to_load
=
[]
models_to_load
=
[]
models_already_loaded
=
[]
models_already_loaded
=
[]
for
x
in
models
:
for
x
in
models
:
...
...
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