Spaces:
Runtime error
Runtime error
Caroline Mai Chan
commited on
Commit
•
764782e
1
Parent(s):
4f625a2
add title, example
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import torch
|
|
3 |
import torch.nn as nn
|
4 |
import gradio as gr
|
5 |
from PIL import Image
|
|
|
6 |
|
7 |
norm_layer = nn.InstanceNorm2d
|
8 |
|
@@ -86,13 +87,24 @@ model = Generator(3, 1, 3)
|
|
86 |
model.load_state_dict(torch.load('model.pth', map_location=torch.device('cpu')))
|
87 |
model.eval()
|
88 |
|
|
|
|
|
|
|
|
|
89 |
def predict(input_img):
|
90 |
input_img = Image.open(input_img)
|
91 |
ratio = 256.0 / input_img.size[1]
|
92 |
input_img = input_img.resize((int(ratio*input_img.size[0]),256), Image.ANTIALIAS)
|
|
|
|
|
93 |
return input_img
|
94 |
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
-
iface = gr.Interface(predict, gr.inputs.Image(type='filepath'), "image")
|
97 |
|
98 |
iface.launch()
|
|
|
3 |
import torch.nn as nn
|
4 |
import gradio as gr
|
5 |
from PIL import Image
|
6 |
+
import torchvision.transforms as transforms
|
7 |
|
8 |
norm_layer = nn.InstanceNorm2d
|
9 |
|
|
|
87 |
model.load_state_dict(torch.load('model.pth', map_location=torch.device('cpu')))
|
88 |
model.eval()
|
89 |
|
90 |
+
transforms_r = [transforms.Resize(int(opt.size), Image.BICUBIC),
|
91 |
+
transforms.ToTensor()]
|
92 |
+
transforms.Compose([transforms.Resize(int(opt.size), Image.BICUBIC), transforms.ToTensor()])
|
93 |
+
|
94 |
def predict(input_img):
|
95 |
input_img = Image.open(input_img)
|
96 |
ratio = 256.0 / input_img.size[1]
|
97 |
input_img = input_img.resize((int(ratio*input_img.size[0]),256), Image.ANTIALIAS)
|
98 |
+
|
99 |
+
|
100 |
return input_img
|
101 |
|
102 |
+
title="informative-drawings"
|
103 |
+
description="Gradio Demo for line drawing generation. "
|
104 |
+
article = "<p style='text-align: center'><a href='https://film-net.github.io/' target='_blank'>FILM: Frame Interpolation for Large Motion</a> | <a href='https://github.com/google-research/frame-interpolation' target='_blank'>Github Repo</a></p>"
|
105 |
+
examples=[['cat.png']]
|
106 |
+
|
107 |
|
108 |
+
iface = gr.Interface(predict, gr.inputs.Image(type='filepath'), "image", title=title,description=description,article=article,examples=examples)
|
109 |
|
110 |
iface.launch()
|
cat.png
ADDED