import os # os.system("wget https://github.com/JingyunLiang/SwinIR/releases/download/v0.0/003_realSR_BSRGAN_DFOWMFC_s64w8_SwinIR-L_x4_GAN.pth -P experiments/pretrained_models") import gradio as gr from PIL import Image, ImageOps import numpy as np if not os.path.exists("data"): os.mkdir("data") if not os.path.exists("dataout"): os.mkdir("dataout") # os.rename("003_realSR_BSRGAN_DFOWMFC_s64w8_SwinIR-L_x4_GAN.pth", "experiments/pretrained_models/003_realSR_BSRGAN_DFOWMFC_s64w8_SwinIR-L_x4_GAN.pth") def infer(img): img = ImageOps.contain(img, (700, 700)) width, height = img.size img.save("./data/data.png") # os.system('python ./SwinIR/main_test_swinir.py --task real_sr --model_path ./experiments/pretrained_models/003_realSR_BSRGAN_DFOWMFC_s64w8_SwinIR-L_x4_GAN.pth --folder_lq ./data/ --scale 4 --large_model --tile 640') return "./results/data.png" inputs = [gr.inputs.Image(type='pil', label="Original Image")] outputs = [gr.outputs.Image(type="file", label="output")] 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 = "

SwinIR: Image Restoration Using Swin Transformer | Github Repo

" examples = [ ['butterfly.png'] ] gr.Interface(infer, inputs, outputs, title=title, description=description, article=article, examples=examples).launch( enable_queue=True, cache_examples=True)