Spaces:
Running
Running
File size: 2,472 Bytes
7a5d543 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
import gradio as gr
from utils.detector import detect_clothing
from utils.advisor import get_advice
def run_style_savvy(image, bg_remove, body_type, face_shape, gender, occasion):
items = detect_clothing(image, do_bg_remove=bg_remove)
advice_list = get_advice(items, body_type, face_shape, gender, occasion)
unique_advice = []
seen = set()
for tip in advice_list:
if tip not in seen:
unique_advice.append(tip)
seen.add(tip)
html = """
<div style="
background-color: #1e1e1e;
color: #f5f5f5;
padding: 24px;
border-radius: 16px;
max-width: 640px;
margin: auto;
font-family: 'Segoe UI', sans-serif;
">
<h2 style="
margin-top: 0;
font-size: 2em;
color: #ff8c00;
text-align: center;
text-transform: uppercase;
">
β¨ Your Personalized Style Tips β¨
</h2>
<ol style="
padding-left: 20px;
font-size: 1.2em;
line-height: 1.8;
">
"""
for advice in unique_advice:
html += f"<li style='margin-bottom: 12px;'>{advice}</li>"
html += "</ol></div>"
return html
with gr.Blocks(theme=gr.themes.Soft()) as demo:
gr.Markdown("## π StyleSavvy β AI Fashion Consultant")
gr.Markdown("Upload your photo and get personalized fashion advice tailored to your features and occasion.")
with gr.Row():
with gr.Column(scale=1):
with gr.Group():
gr.Markdown("### π§Ύ Style Details")
bg_remove = gr.Checkbox(label="Remove Background")
body_type = gr.Radio(["Slim", "Athletic", "Curvy", "Plus-size"], label="Body Type")
face_shape = gr.Radio(["Oval", "Round", "Square", "Heart"], label="Face Shape")
gender = gr.Radio(["Male", "Female"], label="Gender")
occasion = gr.Textbox(label="Occasion", placeholder="e.g. Wedding, Office Party")
with gr.Column(scale=1):
with gr.Group():
gr.Markdown("### πΈ Upload Your Look")
image = gr.Image(type="pil", label="Upload Photo")
submit_btn = gr.Button("β¨ Generate Style Tips")
output = gr.HTML()
submit_btn.click(
fn=run_style_savvy,
inputs=[image, bg_remove, body_type, face_shape, gender, occasion],
outputs=output
)
if __name__ == "__main__":
demo.launch() |