mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-10 14:20:49 +08:00
Merge a0f6703f05 into a60b7b86c5
This commit is contained in:
commit
4c4681f420
@ -78,20 +78,19 @@ class ImageUpscaleWithModel(io.ComfyNode):
|
|||||||
overlap = 32
|
overlap = 32
|
||||||
|
|
||||||
oom = True
|
oom = True
|
||||||
try:
|
while oom:
|
||||||
while oom:
|
try:
|
||||||
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)
|
# KEY CHANGE: Pass device as output_device instead of default "cpu"
|
||||||
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, output_device=device, pbar=pbar)
|
||||||
oom = False
|
oom = False
|
||||||
except model_management.OOM_EXCEPTION as e:
|
except model_management.OOM_EXCEPTION as e:
|
||||||
tile //= 2
|
tile //= 2
|
||||||
if tile < 128:
|
if tile < 128:
|
||||||
raise e
|
raise e
|
||||||
finally:
|
|
||||||
upscale_model.to("cpu")
|
|
||||||
|
|
||||||
|
# upscale_model.to("cpu") # Commented out to keep model on GPU because when processing batch images then model unnecessarily moves to 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 io.NodeOutput(s)
|
return io.NodeOutput(s)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user