File size: 1,727 Bytes
d1dfe2f
fbc62a1
9320c3b
 
bf2220c
9320c3b
 
 
 
 
d1dfe2f
 
 
 
 
b3c88ac
 
 
 
 
 
 
 
 
 
bf2220c
 
 
b3c88ac
 
 
 
 
 
 
 
 
0fc7951
 
b3c88ac
 
 
 
9320c3b
 
 
 
b3c88ac
d1dfe2f
 
2f3dd60
3ec167a
d1dfe2f
fbc62a1
2721e7b
d1dfe2f
 
 
 
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import gradio as gr
import numpy as np


import torch
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'
  #  imagee = Image.open(requests.get(url, stream=True).raw)
  #  model = EdsrModel.from_pretrained('eugenesiow/edsr-base', scale=4)
  #  inputs = ImageLoader.load_image(imagee)
 #   preds = model(inputs)
 #   print("1  :",preds)
 #   print( type(preds) )
 #   prednumpy=preds.detach().numpy()
    

    #preds=np.array(preds)
 #   print("2 :",prednumpy)
 #   ImageLoader.save_image(preds, './scaled_2x.png')
 #   ImageLoader.save_compare(inputs, preds, './scaled_2x_compare.png')

    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=2)
    inputs = ImageLoader.load_image(image)
    preds = model(inputs)
  #  ImageLoader.save_image(preds, './scaled_2x.png')
  #  ImageLoader.save_compare(inputs, preds, './scaled_2x_compare.png')
    prednumpy=preds.detach().numpy()
    return prednumpy

    


    
  #  large_image = cartoon_upsampling_8x(image, 'a_8x_larger_output_image.png' )
 #   return prednumpy

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()