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
a51f33ee
"include/vscode:/vscode.git/clone" did not exist on "774c9209e08d025db1a39a6d81bd130afd53e4c9"
Commit
a51f33ee
authored
Jul 24, 2023
by
comfyanonymous
Browse files
Use bigger tiles when upscaling with model and fallback on OOM.
parent
5f75d784
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
comfy_extras/nodes_upscale_model.py
comfy_extras/nodes_upscale_model.py
+16
-5
No files found.
comfy_extras/nodes_upscale_model.py
View file @
a51f33ee
...
@@ -37,12 +37,23 @@ class ImageUpscaleWithModel:
...
@@ -37,12 +37,23 @@ class ImageUpscaleWithModel:
device
=
model_management
.
get_torch_device
()
device
=
model_management
.
get_torch_device
()
upscale_model
.
to
(
device
)
upscale_model
.
to
(
device
)
in_img
=
image
.
movedim
(
-
1
,
-
3
).
to
(
device
)
in_img
=
image
.
movedim
(
-
1
,
-
3
).
to
(
device
)
free_memory
=
model_management
.
get_free_memory
(
device
)
tile
=
128
+
64
tile
=
512
overlap
=
8
overlap
=
32
oom
=
True
while
oom
:
try
:
steps
=
in_img
.
shape
[
0
]
*
comfy
.
utils
.
get_tiled_scale_steps
(
in_img
.
shape
[
3
],
in_img
.
shape
[
2
],
tile_x
=
tile
,
tile_y
=
tile
,
overlap
=
overlap
)
steps
=
in_img
.
shape
[
0
]
*
comfy
.
utils
.
get_tiled_scale_steps
(
in_img
.
shape
[
3
],
in_img
.
shape
[
2
],
tile_x
=
tile
,
tile_y
=
tile
,
overlap
=
overlap
)
pbar
=
comfy
.
utils
.
ProgressBar
(
steps
)
pbar
=
comfy
.
utils
.
ProgressBar
(
steps
)
s
=
comfy
.
utils
.
tiled_scale
(
in_img
,
lambda
a
:
upscale_model
(
a
),
tile_x
=
tile
,
tile_y
=
tile
,
overlap
=
overlap
,
upscale_amount
=
upscale_model
.
scale
,
pbar
=
pbar
)
s
=
comfy
.
utils
.
tiled_scale
(
in_img
,
lambda
a
:
upscale_model
(
a
),
tile_x
=
tile
,
tile_y
=
tile
,
overlap
=
overlap
,
upscale_amount
=
upscale_model
.
scale
,
pbar
=
pbar
)
oom
=
False
except
model_management
.
OOM_EXCEPTION
as
e
:
tile
//=
2
if
tile
<
128
:
raise
e
upscale_model
.
cpu
()
upscale_model
.
cpu
()
s
=
torch
.
clamp
(
s
.
movedim
(
-
3
,
-
1
),
min
=
0
,
max
=
1.0
)
s
=
torch
.
clamp
(
s
.
movedim
(
-
3
,
-
1
),
min
=
0
,
max
=
1.0
)
return
(
s
,)
return
(
s
,)
...
...
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