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
f00471cd
"tests/pipelines/vscode:/vscode.git/clone" did not exist on "1dc231d14a48bd5ac48e53a5fa283e59da48673a"
Commit
f00471cd
authored
Sep 24, 2023
by
comfyanonymous
Browse files
Do FreeU fft on CPU if the device doesn't support fft functions.
parent
77c124c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
comfy_extras/nodes_freelunch.py
comfy_extras/nodes_freelunch.py
+12
-1
No files found.
comfy_extras/nodes_freelunch.py
View file @
f00471cd
...
...
@@ -39,11 +39,22 @@ class FreeU:
def
patch
(
self
,
model
,
b1
,
b2
,
s1
,
s2
):
model_channels
=
model
.
model
.
model_config
.
unet_config
[
"model_channels"
]
scale_dict
=
{
model_channels
*
4
:
(
b1
,
s1
),
model_channels
*
2
:
(
b2
,
s2
)}
on_cpu_devices
=
{}
def
output_block_patch
(
h
,
hsp
,
transformer_options
):
scale
=
scale_dict
.
get
(
h
.
shape
[
1
],
None
)
if
scale
is
not
None
:
h
[:,:
h
.
shape
[
1
]
//
2
]
=
h
[:,:
h
.
shape
[
1
]
//
2
]
*
scale
[
0
]
hsp
=
Fourier_filter
(
hsp
,
threshold
=
1
,
scale
=
scale
[
1
])
if
hsp
.
device
not
in
on_cpu_devices
:
try
:
hsp
=
Fourier_filter
(
hsp
,
threshold
=
1
,
scale
=
scale
[
1
])
except
:
print
(
"Device"
,
hsp
.
device
,
"does not support the torch.fft functions used in the FreeU node, switching to CPU."
)
on_cpu_devices
[
hsp
.
device
]
=
True
hsp
=
Fourier_filter
(
hsp
.
cpu
(),
threshold
=
1
,
scale
=
scale
[
1
]).
to
(
hsp
.
device
)
else
:
hsp
=
Fourier_filter
(
hsp
.
cpu
(),
threshold
=
1
,
scale
=
scale
[
1
]).
to
(
hsp
.
device
)
return
h
,
hsp
m
=
model
.
clone
()
...
...
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