Spaces:
Running
Running
Create app.py
Browse files
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()
|