|
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 "./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) |