Spaces:
Sleeping
Sleeping
Siyun He
commited on
Commit
·
03ede8d
1
Parent(s):
27ea583
improve gradio interface
Browse files
app.py
CHANGED
@@ -309,27 +309,41 @@ def webcam_input(frame, transform, lip_color):
|
|
309 |
return frame, face_shape, glass_shape
|
310 |
|
311 |
|
312 |
-
|
313 |
-
# Gradio Interface
|
314 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="purple", secondary_hue="blue")) as demo:
|
315 |
gr.Markdown("<h1 style='text-align: center; font-weight: bold;'>🤓 Glasses Virtual Try-On 🕶️👓</h1>")
|
316 |
with gr.Column(elem_classes=["my-column"]):
|
317 |
with gr.Group(elem_classes=["my-group"]):
|
318 |
-
gr.Markdown("<
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
input_img = gr.Image(sources=["webcam"], type="numpy", streaming=True)
|
325 |
-
gr.Markdown("Face Shape and Recommended Glass Shape")
|
326 |
-
face_shape_output = gr.Textbox(label="Detected Face Shape")
|
327 |
-
glass_shape_output = gr.Textbox(label="Recommended Glass Shape")
|
328 |
next_button = gr.Button("Next Glasses➡️")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
save_button = gr.Button("Save as a Picture📌")
|
330 |
-
|
|
|
|
|
331 |
download_link = gr.File(label="Download Saved Picture")
|
|
|
332 |
input_img.stream(webcam_input, [input_img, transform, lip_color], [input_img, face_shape_output, glass_shape_output], stream_every=0.1)
|
|
|
333 |
with gr.Row():
|
334 |
next_button.click(change_glasses, [], [])
|
335 |
with gr.Row():
|
|
|
309 |
return frame, face_shape, glass_shape
|
310 |
|
311 |
|
312 |
+
# Gradio interface
|
|
|
313 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="purple", secondary_hue="blue")) as demo:
|
314 |
gr.Markdown("<h1 style='text-align: center; font-weight: bold;'>🤓 Glasses Virtual Try-On 🕶️👓</h1>")
|
315 |
with gr.Column(elem_classes=["my-column"]):
|
316 |
with gr.Group(elem_classes=["my-group"]):
|
317 |
+
gr.Markdown("<p style='text-align: left; color: purple;'>🟣You can only apply one filter at a time, either the transform filter or the lip color filter.</p>")
|
318 |
+
# Two filters: transform and lip color
|
319 |
+
with gr.Row():
|
320 |
+
transform = gr.Dropdown(
|
321 |
+
choices=["cartoon", "edges", "sepia", "negative", "sketch", "blur", "none"],
|
322 |
+
value="none", label="Select Filter"
|
323 |
+
)
|
324 |
+
|
325 |
+
lip_color = gr.Dropdown(
|
326 |
+
choices=["classic_red", "deep_red", "cherry_red", "rose_red", "wine_red", "brick_red", "coral_red", "berry_red", "ruby_red", "crimson_red", "none"],
|
327 |
+
value="none", label="Select Lip Color"
|
328 |
+
)
|
329 |
+
gr.Markdown("<p style='text-align: left; font-weight: bold; color: purple;'>🟣Click the Webcam icon to start the camera, and then press the record button to start the virtual try-on.</p>")
|
330 |
input_img = gr.Image(sources=["webcam"], type="numpy", streaming=True)
|
|
|
|
|
|
|
331 |
next_button = gr.Button("Next Glasses➡️")
|
332 |
+
gr.Markdown("<p style='text-align: left; color: purple;'>🟣Face Shape and Recommended Glass Shape</p>")
|
333 |
+
|
334 |
+
# Face shape and recommended glass shape
|
335 |
+
with gr.Row():
|
336 |
+
face_shape_output = gr.Textbox(label="Detected Face Shape")
|
337 |
+
glass_shape_output = gr.Textbox(label="Recommended Glass Shape")
|
338 |
+
|
339 |
save_button = gr.Button("Save as a Picture📌")
|
340 |
+
|
341 |
+
gr.Markdown("<p style='text-align: left; color: red;'>‼️Warning: Refresh the page after saving the picture to use the virtual try-on again.</p>")
|
342 |
+
|
343 |
download_link = gr.File(label="Download Saved Picture")
|
344 |
+
|
345 |
input_img.stream(webcam_input, [input_img, transform, lip_color], [input_img, face_shape_output, glass_shape_output], stream_every=0.1)
|
346 |
+
|
347 |
with gr.Row():
|
348 |
next_button.click(change_glasses, [], [])
|
349 |
with gr.Row():
|