Spaces:
Runtime error
Runtime error
Update app.py
Browse filesupdate app to only compute complex lines
app.py
CHANGED
|
@@ -87,9 +87,9 @@ model1 = Generator(3, 1, 3)
|
|
| 87 |
model1.load_state_dict(torch.load('model.pth', map_location=torch.device('cpu')))
|
| 88 |
model1.eval()
|
| 89 |
|
| 90 |
-
model2 = Generator(3, 1, 3)
|
| 91 |
-
model2.load_state_dict(torch.load('model2.pth', map_location=torch.device('cpu')))
|
| 92 |
-
model2.eval()
|
| 93 |
|
| 94 |
def predict(input_img, ver):
|
| 95 |
input_img = Image.open(input_img)
|
|
@@ -99,29 +99,19 @@ def predict(input_img, ver):
|
|
| 99 |
|
| 100 |
drawing = 0
|
| 101 |
with torch.no_grad():
|
| 102 |
-
if ver == 'Simple Lines':
|
| 103 |
-
drawing = model2(input_img)[0].detach()
|
| 104 |
-
else:
|
| 105 |
drawing = model1(input_img)[0].detach()
|
| 106 |
|
| 107 |
drawing = transforms.ToPILImage()(drawing)
|
| 108 |
return drawing
|
| 109 |
|
| 110 |
-
title="Image to
|
| 111 |
-
examples=[
|
| 112 |
-
['01.jpeg', '
|
| 113 |
-
|
| 114 |
-
['10.jpeg', 'Simple Lines'], ['11.jpeg', 'Simple Lines'], ['12.jpeg', 'Simple Lines'],
|
| 115 |
-
['01.jpeg', 'Complex Lines'], ['02.jpeg', 'Complex Lines'], ['03.jpeg', 'Complex Lines'],
|
| 116 |
-
['04.jpeg', 'Simple Lines'], ['05.jpeg', 'Simple Lines'], ['06.jpeg', 'Simple Lines'],
|
| 117 |
-
['07.jpeg', 'Simple Lines'], ['08.jpeg', 'Simple Lines'], ['09.jpeg', 'Simple Lines'],
|
| 118 |
-
['04.jpeg', 'Complex Lines'], ['05.jpeg', 'Complex Lines'], ['06.jpeg', 'Complex Lines'],
|
| 119 |
-
['10.jpeg', 'Complex Lines'], ['11.jpeg', 'Complex Lines'], ['12.jpeg', 'Complex Lines'],
|
| 120 |
-
['Upload Wild Horses 2.jpeg', 'Complex Lines']
|
| 121 |
]
|
| 122 |
|
| 123 |
iface = gr.Interface(predict, [gr.inputs.Image(type='filepath'),
|
| 124 |
-
gr.inputs.Radio(['Complex Lines'
|
| 125 |
gr.outputs.Image(type="pil"), title=title,examples=examples)
|
| 126 |
|
| 127 |
iface.launch()
|
|
|
|
| 87 |
model1.load_state_dict(torch.load('model.pth', map_location=torch.device('cpu')))
|
| 88 |
model1.eval()
|
| 89 |
|
| 90 |
+
# model2 = Generator(3, 1, 3)
|
| 91 |
+
# model2.load_state_dict(torch.load('model2.pth', map_location=torch.device('cpu')))
|
| 92 |
+
# model2.eval()
|
| 93 |
|
| 94 |
def predict(input_img, ver):
|
| 95 |
input_img = Image.open(input_img)
|
|
|
|
| 99 |
|
| 100 |
drawing = 0
|
| 101 |
with torch.no_grad():
|
|
|
|
|
|
|
|
|
|
| 102 |
drawing = model1(input_img)[0].detach()
|
| 103 |
|
| 104 |
drawing = transforms.ToPILImage()(drawing)
|
| 105 |
return drawing
|
| 106 |
|
| 107 |
+
# title="Image to Coloring Page Generator"
|
| 108 |
+
# examples=[
|
| 109 |
+
# ['01.jpeg', 'Complex Lines'],
|
| 110 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
]
|
| 112 |
|
| 113 |
iface = gr.Interface(predict, [gr.inputs.Image(type='filepath'),
|
| 114 |
+
gr.inputs.Radio(['Complex Lines'], type="value", default='Complex Lines', label='version')],
|
| 115 |
gr.outputs.Image(type="pil"), title=title,examples=examples)
|
| 116 |
|
| 117 |
iface.launch()
|