Spaces:
Runtime error
Runtime error
johnowhitaker
commited on
Commit
•
af1001b
1
Parent(s):
603b967
Added title and description, removed unneeded itemgetter funcs
Browse files
app.py
CHANGED
@@ -17,14 +17,9 @@ if not exists(model_fn):
|
|
17 |
else:
|
18 |
print('file exists')
|
19 |
|
20 |
-
# Load the model
|
21 |
-
def
|
22 |
-
def
|
23 |
-
return get_image_files(path/'train') + get_image_files(path/'test')
|
24 |
-
def get_x(item):
|
25 |
-
return np.array(open_img(item).crop((0, 0, 512, 512)))
|
26 |
-
def get_y(item):
|
27 |
-
return np.array(open_img(item).crop((512, 0, 1024, 512)))
|
28 |
sketch_model = load_learner(model_fn)
|
29 |
|
30 |
|
@@ -33,10 +28,19 @@ def sketchify(image_path):
|
|
33 |
np_im = pred[0].permute(1, 2, 0).numpy()
|
34 |
return np_im
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
|
38 |
iface = gr.Interface(fn=sketchify,
|
39 |
-
inputs=[gr.inputs.Image(shape=(512, 512), type="filepath")],
|
40 |
-
outputs=[gr.outputs.Image(type="numpy", label="Output
|
|
|
41 |
)
|
42 |
iface.launch()
|
|
|
17 |
else:
|
18 |
print('file exists')
|
19 |
|
20 |
+
# Load the model (requires dummy itemgetters)
|
21 |
+
def get_x(item):return None
|
22 |
+
def get_y(item):return None
|
|
|
|
|
|
|
|
|
|
|
23 |
sketch_model = load_learner(model_fn)
|
24 |
|
25 |
|
|
|
28 |
np_im = pred[0].permute(1, 2, 0).numpy()
|
29 |
return np_im
|
30 |
|
31 |
+
title = "Sketchy Unet Demo"
|
32 |
+
description = """
|
33 |
+
<center>
|
34 |
+
A resnet34-based unet model trained (briefly) to sketchify faces.
|
35 |
+
</center>
|
36 |
+
"""
|
37 |
+
|
38 |
+
article = "Blog post on this with more details coming soon on https://datasciencecastnet.home.blog/"
|
39 |
|
40 |
|
41 |
iface = gr.Interface(fn=sketchify,
|
42 |
+
inputs=[gr.inputs.Image(label="Input Image", shape=(512, 512), type="filepath")],
|
43 |
+
outputs=[gr.outputs.Image(type="numpy", label="Model Output")],
|
44 |
+
title = title, description = description, article = article
|
45 |
)
|
46 |
iface.launch()
|