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
c77f02e1
Commit
c77f02e1
authored
Aug 25, 2023
by
comfyanonymous
Browse files
Move controlnet code to comfy/controlnet.py
parent
15a7716f
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
533 additions
and
527 deletions
+533
-527
comfy/controlnet.py
comfy/controlnet.py
+483
-0
comfy/sd.py
comfy/sd.py
+33
-525
comfy/utils.py
comfy/utils.py
+14
-0
nodes.py
nodes.py
+3
-2
No files found.
comfy/controlnet.py
0 → 100644
View file @
c77f02e1
This diff is collapsed.
Click to expand it.
comfy/sd.py
View file @
c77f02e1
This diff is collapsed.
Click to expand it.
comfy/utils.py
View file @
c77f02e1
...
...
@@ -237,6 +237,20 @@ def safetensors_header(safetensors_path, max_size=100*1024*1024):
return
None
return
f
.
read
(
length_of_header
)
def
set_attr
(
obj
,
attr
,
value
):
attrs
=
attr
.
split
(
"."
)
for
name
in
attrs
[:
-
1
]:
obj
=
getattr
(
obj
,
name
)
prev
=
getattr
(
obj
,
attrs
[
-
1
])
setattr
(
obj
,
attrs
[
-
1
],
torch
.
nn
.
Parameter
(
value
))
del
prev
def
get_attr
(
obj
,
attr
):
attrs
=
attr
.
split
(
"."
)
for
name
in
attrs
:
obj
=
getattr
(
obj
,
name
)
return
obj
def
bislerp
(
samples
,
width
,
height
):
def
slerp
(
b1
,
b2
,
r
):
'''slerps batches b1, b2 according to ratio r, batches should be flat e.g. NxC'''
...
...
nodes.py
View file @
c77f02e1
...
...
@@ -22,6 +22,7 @@ import comfy.samplers
import
comfy.sample
import
comfy.sd
import
comfy.utils
import
comfy.controlnet
import
comfy.clip_vision
...
...
@@ -569,7 +570,7 @@ class ControlNetLoader:
def
load_controlnet
(
self
,
control_net_name
):
controlnet_path
=
folder_paths
.
get_full_path
(
"controlnet"
,
control_net_name
)
controlnet
=
comfy
.
sd
.
load_controlnet
(
controlnet_path
)
controlnet
=
comfy
.
controlnet
.
load_controlnet
(
controlnet_path
)
return
(
controlnet
,)
class
DiffControlNetLoader
:
...
...
@@ -585,7 +586,7 @@ class DiffControlNetLoader:
def
load_controlnet
(
self
,
model
,
control_net_name
):
controlnet_path
=
folder_paths
.
get_full_path
(
"controlnet"
,
control_net_name
)
controlnet
=
comfy
.
sd
.
load_controlnet
(
controlnet_path
,
model
)
controlnet
=
comfy
.
controlnet
.
load_controlnet
(
controlnet_path
,
model
)
return
(
controlnet
,)
...
...
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