openfree commited on
Commit
2818ef3
1 Parent(s): d1aa623

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -573,7 +573,6 @@ def infer_upscale(
573
 
574
  input_image, w_original, h_original, was_resized = process_input(input_image, upscale_factor)
575
 
576
-
577
  # rescale with upscale factor
578
  w, h = input_image.size
579
  control_image = input_image.resize((w * upscale_factor, h * upscale_factor))
@@ -583,7 +582,12 @@ def infer_upscale(
583
  gr.Info("Upscaling image...")
584
  # 모든 텐서를 동일한 디바이스로 이동
585
  pipe_upscale.to(device)
586
- control_image = torch.from_numpy(np.array(control_image)).permute(2, 0, 1).float().to(device)
 
 
 
 
 
587
 
588
  image = pipe_upscale(
589
  prompt="",
@@ -602,10 +606,12 @@ def infer_upscale(
602
  # resize to target desired size
603
  image = image.resize((w_original * upscale_factor, h_original * upscale_factor))
604
 
605
-
606
 
607
  except Exception as e:
608
  print(f"Error in infer_upscale: {str(e)}")
 
 
609
  return None, seed
610
 
611
 
 
573
 
574
  input_image, w_original, h_original, was_resized = process_input(input_image, upscale_factor)
575
 
 
576
  # rescale with upscale factor
577
  w, h = input_image.size
578
  control_image = input_image.resize((w * upscale_factor, h * upscale_factor))
 
582
  gr.Info("Upscaling image...")
583
  # 모든 텐서를 동일한 디바이스로 이동
584
  pipe_upscale.to(device)
585
+
586
+ # Ensure the image is in RGB format
587
+ if control_image.mode != 'RGB':
588
+ control_image = control_image.convert('RGB')
589
+
590
+ control_image = torch.from_numpy(np.array(control_image)).permute(2, 0, 1).float().to(device) / 255.0
591
 
592
  image = pipe_upscale(
593
  prompt="",
 
606
  # resize to target desired size
607
  image = image.resize((w_original * upscale_factor, h_original * upscale_factor))
608
 
609
+ return image, seed
610
 
611
  except Exception as e:
612
  print(f"Error in infer_upscale: {str(e)}")
613
+ import traceback
614
+ traceback.print_exc()
615
  return None, seed
616
 
617