Manjushri commited on
Commit
14f8699
·
1 Parent(s): 1281d06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  import torch
3
- from torchvision.transforms import ToPILImage, ToTensor
 
4
  from diffusers import StableDiffusionLatentUpscalePipeline, StableDiffusionUpscalePipeline
5
 
6
  device = "cuda" if torch.cuda.is_available() else "cpu"
@@ -19,16 +20,18 @@ output_image = gr.outputs.Image(type="filepath")
19
  # Define the function that will be called when the interface is used
20
  def upscale_image(model, image):
21
  # Convert the image to a PyTorch tensor
22
- image_tensor = ToTensor()(image)
 
 
23
 
24
  # Upscale the image using the selected model
25
  if model == "SD 2.0 2x Latent Upscaler":
26
- upscaled_tensor = sd_2_0_2x(image_tensor)
27
  else:
28
- upscaled_tensor = sd_2_1_4x(image_tensor)
29
 
30
  # Convert the upscaled tensor back to a PIL image
31
- upscaled_image = ToPILImage()(upscaled_tensor)
32
 
33
  # Return the upscaled image
34
  return upscaled_image
 
1
  import gradio as gr
2
  import torch
3
+ from PIL import Image
4
+ from io import BytesIO
5
  from diffusers import StableDiffusionLatentUpscalePipeline, StableDiffusionUpscalePipeline
6
 
7
  device = "cuda" if torch.cuda.is_available() else "cpu"
 
20
  # Define the function that will be called when the interface is used
21
  def upscale_image(model, image):
22
  # Convert the image to a PyTorch tensor
23
+ generator = torch.manual_seed(999999)
24
+ low_res_img = Image.open(low_res_img).convert("RGB")
25
+ low_res_latents = low_res_img
26
 
27
  # Upscale the image using the selected model
28
  if model == "SD 2.0 2x Latent Upscaler":
29
+ upscaled_image = sd_2_0_2x(image)
30
  else:
31
+ upscaled_image = sd_2_1_4x(image)
32
 
33
  # Convert the upscaled tensor back to a PIL image
34
+
35
 
36
  # Return the upscaled image
37
  return upscaled_image