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, occasion): # 1) Detect garments items = detect_clothing(image, do_bg_remove=bg_remove) # 2) Get raw advice string advice_text = get_advice(items, body_type, face_shape, occasion) # 3) Parse out up to 5 tips tips = [] for line in advice_text.splitlines(): ln = line.strip() # catch bullets ("- …", "* …") or numbered ("1. …") or plain if ln.startswith(("-", "*")) or (len(ln) > 1 and ln[0].isdigit() and ln[1] in ". "): tips.append(ln.lstrip("-*0123456789. ").strip()) if not tips: # fallback: split on sentences parts = [p.strip() for p in advice_text.split(".") if p.strip()] tips = parts[:5] tips = tips[:5] # ensure max 5 # 4) Build dark-themed HTML html = """