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 = """

โœจ Your Personalized Style Tips โœจ

    """ for advice in unique_advice: html += f"
  1. {advice}
  2. " html += "
" 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()