romi2001 commited on
Commit
5a7d056
·
verified ·
1 Parent(s): 1d85b0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +57 -12
app.py CHANGED
@@ -388,7 +388,41 @@ def pil_to_base64(img, max_size=420):
388
  return base64.b64encode(buf.getvalue()).decode("utf-8")
389
 
390
 
391
- def build_style_card_html(row, caption):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
392
  colors = [c.strip() for c in str(row["recommended_colors"]).split(",") if c.strip()][:4]
393
  swatches = "".join(
394
  f'<div style="text-align:center;margin-right:16px;">'
@@ -400,11 +434,11 @@ def build_style_card_html(row, caption):
400
  palette_name = get_palette_name(row["skin_tone"], row["undertone"])
401
  return f"""
402
  <div style="font-family:inherit;">
403
- <div style="position:relative;overflow:hidden;background:#15131f;color:white;
404
  border-radius:18px;padding:24px 28px;margin-bottom:16px;">
405
  <div style="position:absolute;top:-40px;right:-40px;width:150px;height:150px;border-radius:50%;
406
- background:radial-gradient(circle,#5b2a52,transparent 70%);"></div>
407
- <div style="font-size:11px;letter-spacing:1.5px;color:#f48fb1;font-weight:700;">YOUR COLOR PALETTE</div>
408
  <div style="font-size:30px;font-weight:800;margin:6px 0 4px;">{palette_name}</div>
409
  <div style="font-size:13px;color:#bdb8c9;">
410
  {row['skin_tone'].title()} skin · {row['undertone'].title()} undertone · {row['style_preference'].title()} style
@@ -416,7 +450,7 @@ def build_style_card_html(row, caption):
416
  <div style="display:flex;flex-wrap:wrap;">{swatches}</div>
417
  </div>
418
  <div style="flex:1;min-width:220px;background:#f9fafb;border-radius:14px;padding:18px;">
419
- <div style="font-size:11px;letter-spacing:1.5px;color:#a855f7;font-weight:700;margin-bottom:8px;">STYLIST TIP</div>
420
  <div style="font-size:14px;color:#1f2937;line-height:1.4;">{caption}</div>
421
  </div>
422
  </div>
@@ -446,7 +480,7 @@ def build_outfit_component_cards_html(row):
446
  <div style="width:30px;height:30px;border-radius:50%;background:{dot_color};border:2px solid white;"></div>
447
  </div>
448
  <div style="padding:12px 14px;">
449
- <div style="font-size:10px;letter-spacing:1px;color:#d6336c;font-weight:700;">{label}</div>
450
  <div style="font-size:13px;font-weight:600;margin:4px 0 2px;color:#111827;">{str(item_name).title()}</div>
451
  <div style="font-size:11px;color:#9ca3af;margin-bottom:10px;">{retailer.upper()}</div>
452
  <a href="{link}" target="_blank" style="display:block;text-align:center;background:#111827;
@@ -542,12 +576,18 @@ def recommend_from_features(skin_tone, undertone, style, gender, age_group, ques
542
  # GRADIO UI
543
  # ---------------------------------------------------------------------------
544
  CUSTOM_CSS = """
545
- .gradio-container {font-family: 'Helvetica Neue', Arial, sans-serif;}
546
- #find-btn {font-weight: 700; border-radius: 10px;}
547
- .dark-panel {background: #15131f !important; border-radius: 16px !important; padding: 18px !important;}
548
- .dark-panel label, .dark-panel span {color: #e5e1f0 !important;}
549
- .big-btn {background: #111827 !important; border: none !important; border-radius: 10px !important;
550
- font-size: 16px !important; padding: 12px !important;}
 
 
 
 
 
 
551
  """
552
 
553
  with gr.Blocks(title="AI Fashion Stylist", css=CUSTOM_CSS, theme=gr.themes.Soft(primary_hue="purple")) as demo:
@@ -598,6 +638,11 @@ with gr.Blocks(title="AI Fashion Stylist", css=CUSTOM_CSS, theme=gr.themes.Soft(
598
  question_b = gr.Textbox(label="Ask the stylist a question about the top match (optional)",
599
  placeholder="e.g. Is this outfit formal or casual?")
600
  btn_b = gr.Button("Get My Look ✨", elem_id="find-btn", elem_classes="big-btn", variant="primary")
 
 
 
 
 
601
  style_card_b = gr.HTML(label="Style Profile")
602
  new_img_b = gr.Image(label="✨ Your New AI-Generated Look")
603
  answer_b = gr.Textbox(label="Answer to your question")
 
388
  return base64.b64encode(buf.getvalue()).decode("utf-8")
389
 
390
 
391
+ def build_feature_pills_html(labels, selected, title):
392
+ """Pill-style recap row (her visual pattern) - but built from your real, actually-used
393
+ attributes (skin tone / undertone / style), not placeholder categories."""
394
+ pills = ""
395
+ for label in labels:
396
+ active = label == selected
397
+ border = "2px solid #C94A72" if active else "1.5px solid #E8E0E8"
398
+ bg = "#FFF0F5" if active else "#FFFFFF"
399
+ tcol = "#C94A72" if active else "#444"
400
+ dot = _swatch_color(label) if title != "Style" else "#C19A6B"
401
+ pills += (
402
+ f'<div style="display:inline-flex;align-items:center;gap:7px;padding:8px 14px;'
403
+ f'border-radius:30px;border:{border};background:{bg};margin:4px;">'
404
+ f'<div style="width:14px;height:14px;border-radius:50%;background:{dot};'
405
+ f'border:1px solid rgba(0,0,0,.12);"></div>'
406
+ f'<span style="font-size:13px;font-weight:500;color:{tcol};">{label.title()}</span></div>'
407
+ )
408
+ return (
409
+ f'<div style="margin-bottom:14px;"><div style="font-size:11px;font-weight:600;color:#aaa;'
410
+ f'text-transform:uppercase;letter-spacing:.1em;margin-bottom:8px;">{title}</div>'
411
+ f'<div style="display:flex;flex-wrap:wrap;margin:-4px;">{pills}</div></div>'
412
+ )
413
+
414
+
415
+ def build_features_recap_html(skin_tone, undertone, style):
416
+ return (
417
+ '<div style="background:#fff;border-radius:16px;padding:18px 20px;'
418
+ 'margin-bottom:14px;border:1px solid #F0E8F0;">'
419
+ '<div style="font-size:11px;font-weight:600;color:#C94A72;text-transform:uppercase;'
420
+ 'letter-spacing:.1em;margin-bottom:14px;">Your Features</div>'
421
+ + build_feature_pills_html(SKIN_TONES, skin_tone, "Skin tone")
422
+ + build_feature_pills_html(UNDERTONES, undertone, "Undertone")
423
+ + build_feature_pills_html(STYLES, style, "Style")
424
+ + "</div>"
425
+ )
426
  colors = [c.strip() for c in str(row["recommended_colors"]).split(",") if c.strip()][:4]
427
  swatches = "".join(
428
  f'<div style="text-align:center;margin-right:16px;">'
 
434
  palette_name = get_palette_name(row["skin_tone"], row["undertone"])
435
  return f"""
436
  <div style="font-family:inherit;">
437
+ <div style="position:relative;overflow:hidden;background:#1a1a1a;color:white;
438
  border-radius:18px;padding:24px 28px;margin-bottom:16px;">
439
  <div style="position:absolute;top:-40px;right:-40px;width:150px;height:150px;border-radius:50%;
440
+ background:rgba(201,74,114,.25);"></div>
441
+ <div style="font-size:11px;letter-spacing:1.5px;color:#C94A72;font-weight:700;">YOUR COLOR PALETTE</div>
442
  <div style="font-size:30px;font-weight:800;margin:6px 0 4px;">{palette_name}</div>
443
  <div style="font-size:13px;color:#bdb8c9;">
444
  {row['skin_tone'].title()} skin · {row['undertone'].title()} undertone · {row['style_preference'].title()} style
 
450
  <div style="display:flex;flex-wrap:wrap;">{swatches}</div>
451
  </div>
452
  <div style="flex:1;min-width:220px;background:#f9fafb;border-radius:14px;padding:18px;">
453
+ <div style="font-size:11px;letter-spacing:1.5px;color:#C94A72;font-weight:700;margin-bottom:8px;">STYLIST TIP</div>
454
  <div style="font-size:14px;color:#1f2937;line-height:1.4;">{caption}</div>
455
  </div>
456
  </div>
 
480
  <div style="width:30px;height:30px;border-radius:50%;background:{dot_color};border:2px solid white;"></div>
481
  </div>
482
  <div style="padding:12px 14px;">
483
+ <div style="font-size:10px;letter-spacing:1px;color:#C94A72;font-weight:700;">{label}</div>
484
  <div style="font-size:13px;font-weight:600;margin:4px 0 2px;color:#111827;">{str(item_name).title()}</div>
485
  <div style="font-size:11px;color:#9ca3af;margin-bottom:10px;">{retailer.upper()}</div>
486
  <a href="{link}" target="_blank" style="display:block;text-align:center;background:#111827;
 
576
  # GRADIO UI
577
  # ---------------------------------------------------------------------------
578
  CUSTOM_CSS = """
579
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');
580
+ .gradio-container {font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif !important;
581
+ max-width: 820px !important; margin: auto !important; background: #FAF5F8 !important;}
582
+ .tab-nav button {font-size: 15px !important; font-weight: 600 !important; padding: 12px 24px !important;}
583
+ .tab-nav button.selected {color: #C94A72 !important; border-bottom: 2px solid #C94A72 !important;}
584
+ #find-btn, .big-btn {background: #1a1a1a !important; color: #fff !important; border: none !important;
585
+ border-radius: 12px !important; font-weight: 700 !important; font-size: 15px !important;
586
+ padding: 13px !important; transition: background .2s !important;}
587
+ #find-btn:hover, .big-btn:hover {background: #C94A72 !important;}
588
+ .dark-panel {background: #1a1a1a !important; border-radius: 16px !important; padding: 18px !important;}
589
+ .dark-panel label, .dark-panel span {color: #f0e6ea !important;}
590
+ footer {display: none !important;}
591
  """
592
 
593
  with gr.Blocks(title="AI Fashion Stylist", css=CUSTOM_CSS, theme=gr.themes.Soft(primary_hue="purple")) as demo:
 
638
  question_b = gr.Textbox(label="Ask the stylist a question about the top match (optional)",
639
  placeholder="e.g. Is this outfit formal or casual?")
640
  btn_b = gr.Button("Get My Look ✨", elem_id="find-btn", elem_classes="big-btn", variant="primary")
641
+ features_recap_b = gr.HTML(build_features_recap_html(SKIN_TONES[0], UNDERTONES[0], STYLES[0]))
642
+ for _dropdown in (skin_b, undertone_b, style_b):
643
+ _dropdown.change(
644
+ build_features_recap_html, [skin_b, undertone_b, style_b], features_recap_b
645
+ )
646
  style_card_b = gr.HTML(label="Style Profile")
647
  new_img_b = gr.Image(label="✨ Your New AI-Generated Look")
648
  answer_b = gr.Textbox(label="Answer to your question")