Spaces:
Sleeping
Sleeping
Update
Browse files
app.py
CHANGED
@@ -95,8 +95,7 @@ def main():
|
|
95 |
|
96 |
- Drop an image containing a near-frontal face to the **Input Image**.
|
97 |
- If there are multiple faces in the image, hit the Edit button in the upper right corner and crop the input image beforehand.
|
98 |
-
- Hit the **
|
99 |
-
- Hit the **Reconstruct Face** button.
|
100 |
- 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.
|
101 |
''')
|
102 |
with gr.Row():
|
@@ -105,14 +104,12 @@ def main():
|
|
105 |
input_image = gr.Image(label='Input Image',
|
106 |
type='file')
|
107 |
with gr.Row():
|
108 |
-
|
109 |
with gr.Column():
|
110 |
with gr.Row():
|
111 |
aligned_face = gr.Image(label='Aligned Face',
|
112 |
type='numpy',
|
113 |
interactive=False)
|
114 |
-
with gr.Row():
|
115 |
-
reconstruct_button = gr.Button('Reconstruct Face')
|
116 |
with gr.Column():
|
117 |
reconstructed_face = gr.Image(label='Reconstructed Face',
|
118 |
type='numpy')
|
@@ -193,12 +190,15 @@ def main():
|
|
193 |
|
194 |
gr.Markdown(FOOTER)
|
195 |
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
|
|
|
|
|
|
202 |
style_type.change(fn=update_slider,
|
203 |
inputs=style_type,
|
204 |
outputs=style_index)
|
|
|
95 |
|
96 |
- Drop an image containing a near-frontal face to the **Input Image**.
|
97 |
- If there are multiple faces in the image, hit the Edit button in the upper right corner and crop the input image beforehand.
|
98 |
+
- Hit the **Preprocess** button.
|
|
|
99 |
- 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.
|
100 |
''')
|
101 |
with gr.Row():
|
|
|
104 |
input_image = gr.Image(label='Input Image',
|
105 |
type='file')
|
106 |
with gr.Row():
|
107 |
+
preprocess_button = gr.Button('Preprocess')
|
108 |
with gr.Column():
|
109 |
with gr.Row():
|
110 |
aligned_face = gr.Image(label='Aligned Face',
|
111 |
type='numpy',
|
112 |
interactive=False)
|
|
|
|
|
113 |
with gr.Column():
|
114 |
reconstructed_face = gr.Image(label='Reconstructed Face',
|
115 |
type='numpy')
|
|
|
190 |
|
191 |
gr.Markdown(FOOTER)
|
192 |
|
193 |
+
preprocess_button.click(fn=model.detect_and_align_face,
|
194 |
+
inputs=input_image,
|
195 |
+
outputs=aligned_face)
|
196 |
+
aligned_face.change(fn=model.reconstruct_face,
|
197 |
+
inputs=aligned_face,
|
198 |
+
outputs=[
|
199 |
+
reconstructed_face,
|
200 |
+
instyle,
|
201 |
+
])
|
202 |
style_type.change(fn=update_slider,
|
203 |
inputs=style_type,
|
204 |
outputs=style_index)
|