Spaces:
Runtime error
Runtime error
First model version
Browse files
app.py
CHANGED
@@ -49,16 +49,37 @@ def infer(filepath):
|
|
49 |
visual_image = det_demo.visualization(image.copy(), result_polygons, result_masks, result_boxes, result_words)
|
50 |
|
51 |
cv2.imwrite('result.jpg', visual_image)
|
52 |
-
return 'result.jpg', pd.DataFrame(result_words)
|
53 |
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
- If there are multiple faces in the image, hit the Edit button in the upper right corner and crop the input image beforehand.
|
57 |
-
- Hit the **Detect & Align Face** button.
|
58 |
-
- Hit the **Reconstruct Face** button.
|
59 |
- The final result will be based on this **Reconstructed Face**. So, if the reconstructed image is not satisfactory, you may want to change the input image.
|
60 |
-
''')
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
iface = gr.Interface(
|
63 |
fn=infer,
|
64 |
title="张博强毕设展示",
|
@@ -66,4 +87,5 @@ iface = gr.Interface(
|
|
66 |
inputs=[gr.inputs.Image(label="image", type="filepath")],
|
67 |
outputs=[gr.outputs.Image(), gr.outputs.Dataframe(headers=['word'])],
|
68 |
examples=['figs/test/CANDY.png', 'figs/test/ESPLANADE.png', 'figs/test/KAPPA.png'],
|
69 |
-
).launch(enable_queue=True, cache_examples=True)
|
|
|
|
49 |
visual_image = det_demo.visualization(image.copy(), result_polygons, result_masks, result_boxes, result_words)
|
50 |
|
51 |
cv2.imwrite('result.jpg', visual_image)
|
52 |
+
return ['result.jpg', pd.DataFrame(result_words)]
|
53 |
|
54 |
+
blocks = gr.Blocks()
|
55 |
+
|
56 |
+
input_image = gr.Image(label="image", type="filepath")
|
57 |
+
output_image = gr.Image(label="out_img", type="filepath")
|
58 |
+
output_word = gr.Dataframe(label="out_word", headers=['word'])
|
59 |
+
|
60 |
+
with blocks:
|
61 |
+
description = gr.Markdown('''## Step 1 (Preprocess Input Image)
|
62 |
+
- Drop an image containing a near-frontal face to the **Input Image**.
|
63 |
- If there are multiple faces in the image, hit the Edit button in the upper right corner and crop the input image beforehand.
|
64 |
+
- Hit the **Detect & Align Face** button.
|
65 |
+
- Hit the **Reconstruct Face** button.
|
66 |
- The final result will be based on this **Reconstructed Face**. So, if the reconstructed image is not satisfactory, you may want to change the input image.
|
67 |
+
''')
|
68 |
+
with gr.Row():
|
69 |
+
with gr.Column():
|
70 |
+
input_image.render()
|
71 |
+
button = gr.Button("Submit")
|
72 |
+
button.click(fn=infer, inputs=[input_image],
|
73 |
+
outputs=[output_image, output_word],)
|
74 |
+
with gr.Column():
|
75 |
+
output_image.render()
|
76 |
+
with gr.Row():
|
77 |
+
output_word.render()
|
78 |
+
|
79 |
+
|
80 |
+
if __name__ == "__main__":
|
81 |
+
blocks.launch(debug=True)
|
82 |
+
'''
|
83 |
iface = gr.Interface(
|
84 |
fn=infer,
|
85 |
title="张博强毕设展示",
|
|
|
87 |
inputs=[gr.inputs.Image(label="image", type="filepath")],
|
88 |
outputs=[gr.outputs.Image(), gr.outputs.Dataframe(headers=['word'])],
|
89 |
examples=['figs/test/CANDY.png', 'figs/test/ESPLANADE.png', 'figs/test/KAPPA.png'],
|
90 |
+
).launch(enable_queue=True, cache_examples=True)
|
91 |
+
'''
|