File size: 1,496 Bytes
2c8bbe1 0a00900 f23c87b 599d8a3 1185034 2c8bbe1 6fba779 2c8bbe1 435bf26 79d5442 6fba779 2c8bbe1 435bf26 11b46ec 1185034 1ecbf8c 8eefa03 2c8bbe1 8eefa03 2c8bbe1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import os
import gradio as gr
from PIL import Image, ImageOps
import numpy as np
os.system("pip install opencv-python")
os.system("pip install torch")
os.system("pip install jinja2")
if not os.path.exists("data"):
os.mkdir("data")
if not os.path.exists("results"):
os.mkdir("results")
def infer(img):
width, height = img.size
res=np.ones_like((width, height,3))
print(res.shape)
print(width)
img.save("./data/data.png")
img.save("./results/data.png")
os.system('python main_test_swinir.py')
res=Image.open("./results/data.png")
#return res
return "./results/data.png","./results/data.png"
inputs = [gr.inputs.Image(type='pil', label="Original Image")]
outputs = [gr.outputs.Image(type="file", label="output"), gr.outputs.File(label="download")]
title = "SwinIR: Image Restoration Using Swin Transformer,Super-Resolution part "
description = "Gradio demo for SwinIR: Super-Resolution part. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below."
article = "<p style='text-align: center'><a href='https://arxiv.org/pdf/2108.10257.pdf' target='_blank'>SwinIR: Image Restoration Using Swin Transformer</a> | <a href='https://github.com/JingyunLiang/SwinIR' target='_blank'>Github Repo</a></p>"
examples = [
['butterfly.png']
]
gr.Interface(infer, inputs, outputs, title=title, description=description, article=article, examples=examples).launch(
enable_queue=True, cache_examples=True) |