Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -95,28 +95,37 @@ def analyze_outfit(img: Image.Image):
|
|
| 95 |
|
| 96 |
return category_html, tts_path, response
|
| 97 |
|
| 98 |
-
# Gradio Interface
|
| 99 |
with gr.Blocks(css="""
|
| 100 |
.container { max-width: 600px; margin: 0 auto; padding: 2rem; }
|
| 101 |
button { background-color: #1f04ff; color: white; border: none; padding: 0.75rem 1.5rem; border-radius: 6px; cursor: pointer; font-weight: bold; }
|
| 102 |
button:hover { background-color: #1500cc; }
|
| 103 |
#resultbox { border: 1px solid #e3e3e3; border-radius: 10px; padding: 1rem; background: #fafafa; }
|
| 104 |
""") as demo:
|
|
|
|
| 105 |
with gr.Group(elem_classes=["container"]):
|
| 106 |
-
gr.Markdown("###
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
|
|
|
| 110 |
|
| 111 |
-
|
| 112 |
-
analyze_button_webcam = gr.Button("Analyze Webcam Fit")
|
| 113 |
|
|
|
|
| 114 |
category_html = gr.HTML()
|
| 115 |
audio_output = gr.Audio(autoplay=True, label="")
|
| 116 |
response_box = gr.Textbox(label="Response", lines=2, interactive=False)
|
| 117 |
|
| 118 |
-
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
if __name__ == '__main__':
|
| 122 |
demo.launch()
|
|
|
|
| 95 |
|
| 96 |
return category_html, tts_path, response
|
| 97 |
|
|
|
|
| 98 |
with gr.Blocks(css="""
|
| 99 |
.container { max-width: 600px; margin: 0 auto; padding: 2rem; }
|
| 100 |
button { background-color: #1f04ff; color: white; border: none; padding: 0.75rem 1.5rem; border-radius: 6px; cursor: pointer; font-weight: bold; }
|
| 101 |
button:hover { background-color: #1500cc; }
|
| 102 |
#resultbox { border: 1px solid #e3e3e3; border-radius: 10px; padding: 1rem; background: #fafafa; }
|
| 103 |
""") as demo:
|
| 104 |
+
|
| 105 |
with gr.Group(elem_classes=["container"]):
|
| 106 |
+
gr.Markdown("### Choose an input method:")
|
| 107 |
|
| 108 |
+
with gr.Row():
|
| 109 |
+
webcam_input = gr.Image(label="📸 Take a Photo", image_mode="RGB", type="pil", show_label=False, show_download_button=False, tool=None, sources=["webcam"])
|
| 110 |
+
upload_input = gr.Image(label="🖼️ Upload Photo", image_mode="RGB", type="pil", show_label=False, show_download_button=False, tool=None, sources=["upload"])
|
| 111 |
|
| 112 |
+
analyze_button = gr.Button("🔥 Analyze My Fit")
|
|
|
|
| 113 |
|
| 114 |
+
# Placeholder outputs
|
| 115 |
category_html = gr.HTML()
|
| 116 |
audio_output = gr.Audio(autoplay=True, label="")
|
| 117 |
response_box = gr.Textbox(label="Response", lines=2, interactive=False)
|
| 118 |
|
| 119 |
+
# Merge the two image inputs into one workflow
|
| 120 |
+
def merged_input(image1, image2):
|
| 121 |
+
return image1 if image1 is not None else image2
|
| 122 |
+
|
| 123 |
+
merged = gr.State()
|
| 124 |
+
|
| 125 |
+
webcam_input.change(fn=merged_input, inputs=[webcam_input, upload_input], outputs=merged)
|
| 126 |
+
upload_input.change(fn=merged_input, inputs=[webcam_input, upload_input], outputs=merged)
|
| 127 |
+
|
| 128 |
+
analyze_button.click(fn=analyze_outfit, inputs=[merged], outputs=[category_html, audio_output, response_box])
|
| 129 |
|
| 130 |
if __name__ == '__main__':
|
| 131 |
demo.launch()
|