Skip to content

Commit bf26a40

Browse files
committed
upscaler fix
1 parent e2f811b commit bf26a40

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

modules/upscale_pipeline.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,17 @@ def process(
7777
input_image = np.array(input_image).astype(np.float32) / 255.0
7878
input_image = torch.from_numpy(input_image)[None,]
7979

80+
worker.outputs.append(["preview", (-1, f"Load upscaling model ...", None)])
8081
upscaler_name = controlnet["upscaler"]
81-
worker.outputs.append(["preview", (-1, f"Load upscaling model {upscaler_name}...", None)])
82-
print(f"Upscale: Loading model {upscaler_name}")
8382
upscale_path = path_manager.get_file_path(upscaler_name)
8483
if upscale_path == None:
8584
upscale_path = path_manager.get_file_path("4x-UltraSharp.pth")
85+
upscaler_model = self.load_upscaler_model(upscale_path)
86+
87+
worker.outputs.append(["preview", (-1, f"Upscaling image ...", None)])
88+
decoded_latent = ImageUpscaleWithModel().upscale(
89+
upscaler_model, input_image
90+
)[0]
8691

8792
try:
8893
upscaler_model = self.load_upscaler_model(upscale_path)
@@ -92,17 +97,6 @@ def process(
9297
upscaler_model, input_image
9398
)[0]
9499

95-
worker.outputs.append(["preview", (-1, f"Converting ...", None)])
96-
images = [
97-
np.clip(255.0 * y.cpu().numpy(), 0, 255).astype(np.uint8)
98-
for y in decoded_latent
99-
]
100-
worker.outputs.append(["preview", (-1, f"Done ...", None)])
101-
except:
102-
traceback.print_exc()
103-
worker.outputs.append(["preview", (-1, f"Oops ...", "error.png")])
104-
images = []
105-
106100
worker.outputs.append(["preview", (-1, f"Converting ...", None)])
107101
images = [
108102
np.clip(255.0 * y.cpu().numpy(), 0, 255).astype(np.uint8)

0 commit comments

Comments
 (0)