reedmayhew commited on
Commit
f1ee166
1 Parent(s): e2d6adc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -3,7 +3,7 @@ from PIL import Image
3
  import numpy as np
4
  import torch
5
  from transformers import AutoImageProcessor, Swin2SRForImageSuperResolution
6
- import gradio as gr # Import Gradio for creating the interface
7
  import spaces
8
 
9
  # Function to upscale an image using Swin2SR
@@ -22,7 +22,7 @@ def upscale_image(image, model, processor, device):
22
  outputs = model(**inputs)
23
 
24
  # Move output back to CPU for further processing
25
- output = outputs.reconstruction.data.squeeze().cpu().clamp_(0, 1).numpy()
26
  output = np.moveaxis(output, source=0, destination=-1)
27
  output_image = (output * 255.0).round().astype(np.uint8) # Convert from float32 to uint8
28
 
@@ -66,7 +66,7 @@ interface = gr.Interface(
66
  fn=gradio_interface,
67
  inputs=[
68
  gr.Image(type="pil", label="Upload Image"),
69
- gr.Checkbox(default=True, label="Save as JPEG"),
70
  ],
71
  outputs=gr.File(label="Download Upscaled Image"),
72
  title="Image Upscaler",
 
3
  import numpy as np
4
  import torch
5
  from transformers import AutoImageProcessor, Swin2SRForImageSuperResolution
6
+ import gradio as gr
7
  import spaces
8
 
9
  # Function to upscale an image using Swin2SR
 
22
  outputs = model(**inputs)
23
 
24
  # Move output back to CPU for further processing
25
+ output = outputs.reconstruction.data.squeeze().cpu().float().clamp_(0, 1).numpy()
26
  output = np.moveaxis(output, source=0, destination=-1)
27
  output_image = (output * 255.0).round().astype(np.uint8) # Convert from float32 to uint8
28
 
 
66
  fn=gradio_interface,
67
  inputs=[
68
  gr.Image(type="pil", label="Upload Image"),
69
+ gr.Checkbox(value=True, label="Save as JPEG"),
70
  ],
71
  outputs=gr.File(label="Download Upscaled Image"),
72
  title="Image Upscaler",