Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -566,10 +566,6 @@ def infer_upscale(
|
|
566 |
return None, seed, gr.update(), gr.update(), gr.update(), gr.update(), gr.update(visible=True, value="Please upload an image for upscaling.")
|
567 |
|
568 |
try:
|
569 |
-
|
570 |
-
if input_image is None:
|
571 |
-
return None, seed
|
572 |
-
|
573 |
if randomize_seed:
|
574 |
seed = random.randint(0, MAX_SEED)
|
575 |
|
@@ -609,7 +605,12 @@ def infer_upscale(
|
|
609 |
# resize to target desired size
|
610 |
image = image.resize((w_original * upscale_factor, h_original * upscale_factor))
|
611 |
|
612 |
-
|
|
|
|
|
|
|
|
|
|
|
613 |
|
614 |
return image, seed, num_inference_steps, upscale_factor, controlnet_conditioning_scale, gr.update(), gr.update(visible=False)
|
615 |
except Exception as e:
|
|
|
566 |
return None, seed, gr.update(), gr.update(), gr.update(), gr.update(), gr.update(visible=True, value="Please upload an image for upscaling.")
|
567 |
|
568 |
try:
|
|
|
|
|
|
|
|
|
569 |
if randomize_seed:
|
570 |
seed = random.randint(0, MAX_SEED)
|
571 |
|
|
|
605 |
# resize to target desired size
|
606 |
image = image.resize((w_original * upscale_factor, h_original * upscale_factor))
|
607 |
|
608 |
+
# Convert the image back to PIL Image and ensure proper scaling
|
609 |
+
if isinstance(image, torch.Tensor):
|
610 |
+
image = image.cpu().permute(1, 2, 0).numpy()
|
611 |
+
if image.max() <= 1.0:
|
612 |
+
image = (image * 255).astype(np.uint8)
|
613 |
+
image = Image.fromarray(image)
|
614 |
|
615 |
return image, seed, num_inference_steps, upscale_factor, controlnet_conditioning_scale, gr.update(), gr.update(visible=False)
|
616 |
except Exception as e:
|