myimageupscaler / app.py
Kev09's picture
Update app.py
fbc62a1
raw
history blame
1.11 kB
import gradio as gr
import numpy as np
from super_image import EdsrModel, ImageLoader
from PIL import Image
import requests
def greet(name):
return "Hello " + name + "!!"
def transformation(image):
print(image)
print( type(image) )
url = 'https://paperswithcode.com/media/datasets/Set5-0000002728-07a9793f_zA3bDjj.jpg'
image = Image.open(requests.get(url, stream=True).raw)
model = EdsrModel.from_pretrained('eugenesiow/edsr-base', scale=4)
inputs = ImageLoader.load_image(image)
preds = model(inputs)
preds=np.array(preds)
print(preds)
ImageLoader.save_image(preds, './scaled_2x.png')
ImageLoader.save_compare(inputs, preds, './scaled_2x_compare.png')
# large_image = cartoon_upsampling_8x(image, 'a_8x_larger_output_image.png' )
return preds
with gr.Blocks() as demo:
image1=gr.Image(type='filepath')
button=gr.Button("LE BOUTON")
image2=gr.Image(type='numpy')
button.click(fn=transformation,inputs=image1,outputs=image2,api_name="upscale")
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
demo.launch()