afreedd commited on
Commit
f156073
·
verified ·
1 Parent(s): a1e49e7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ from PIL import Image
4
+ import torch
5
+
6
+ device = "cuda" if torch.cuda.is_available() else "cpu"
7
+ pipe = pipeline(task="image-to-image", model="caidas/swin2SR-lightweight-x2-64", device=device)
8
+
9
+ def upscale_image(image):
10
+ upscaled = pipe(image)
11
+ return upscaled
12
+
13
+ iface = gr.Interface(
14
+ fn=upscale_image,
15
+ inputs=gr.Image(type="pil"),
16
+ outputs=gr.Image(type="pil"),
17
+ title="Image Super Resolution",
18
+ description="Upscale an image using Swin2SR."
19
+ )
20
+
21
+ iface.launch()