Manjushri commited on
Commit
d5b5eda
·
1 Parent(s): ee5f11d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -13,15 +13,12 @@ model_4x = "stabilityai/stable-diffusion-x4-upscaler"
13
  sd_2_0_2x = StableDiffusionLatentUpscalePipelin.from_pretrained(model_2x, torch_dtype=torch.float16, revision="fp16") if torch.cuda.is_available() else StableDiffusionLatentUpscalePipeline.from_pretrained(model_2x)
14
  sd_2_1_4x = StableDiffusionUpscalePipeline.from_pretrained(model_4x, torch_dtype=torch.float16, revision="fp16") if torch.cuda.is_available() else StableDiffusionUpscalePipeline.from_pretrained(model_4x)
15
 
16
- # Define the input and output components for the Gradio interface
17
- input_image = gr.inputs.Image(type="filepath")
18
- output_image = gr.outputs.Image(type="filepath")
19
-
20
  # Define the function that will be called when the interface is used
 
21
  def upscale_image(model, input_image):
22
  # Convert the image to a PyTorch tensor
23
  generator = torch.manual_seed(999999)
24
- image = Image.open(input_image).convert("RGB")
25
 
26
 
27
  # Upscale the image using the selected model
@@ -39,8 +36,8 @@ def upscale_image(model, input_image):
39
  # Define the Gradio interface
40
  iface = gr.Interface(
41
  fn=upscale_image,
42
- inputs=[gr.Radio(["SD 2.0 2x Latent Upscaler", "SD 2.1 4x Upscaler"]), input_image],
43
- outputs=output_image,
44
  title="Image Upscaler",
45
  description="Upscale an image using either the SD 2.0 2x Latent Upscaler or the SD 2.1 4x Upscaler."
46
  )
 
13
  sd_2_0_2x = StableDiffusionLatentUpscalePipelin.from_pretrained(model_2x, torch_dtype=torch.float16, revision="fp16") if torch.cuda.is_available() else StableDiffusionLatentUpscalePipeline.from_pretrained(model_2x)
14
  sd_2_1_4x = StableDiffusionUpscalePipeline.from_pretrained(model_4x, torch_dtype=torch.float16, revision="fp16") if torch.cuda.is_available() else StableDiffusionUpscalePipeline.from_pretrained(model_4x)
15
 
 
 
 
 
16
  # Define the function that will be called when the interface is used
17
+
18
  def upscale_image(model, input_image):
19
  # Convert the image to a PyTorch tensor
20
  generator = torch.manual_seed(999999)
21
+ input_image = Image.open(input_image).convert("RGB")
22
 
23
 
24
  # Upscale the image using the selected model
 
36
  # Define the Gradio interface
37
  iface = gr.Interface(
38
  fn=upscale_image,
39
+ inputs=[gr.Radio(["SD 2.0 2x Latent Upscaler", "SD 2.1 4x Upscaler"]), gr.Image(type="filepath")],
40
+ outputs=gr.Image(type="filepath"),
41
  title="Image Upscaler",
42
  description="Upscale an image using either the SD 2.0 2x Latent Upscaler or the SD 2.1 4x Upscaler."
43
  )