romi2001 commited on
Commit
2fdadb5
·
verified ·
1 Parent(s): 9239539

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -106
app.py CHANGED
@@ -20,7 +20,6 @@ COLOR_PALETTES = {
20
  }
21
  }
22
 
23
- # The precise 6 categories and exact items from your screenshot
24
  RECOMMENDED_LOOKS = {
25
  "Light-Black-Brown": [
26
  {"category": "TOP", "name": "Rust Wrap Blouse", "brand": "SHEIN", "hex": "#C64614", "bg": "#F5E6E1", "url": "https://www.shein.com"},
@@ -48,7 +47,7 @@ def analyze_and_recommend(image, skin, hair, eye, choice_method):
48
  for s in palette["swatches"]
49
  ])
50
 
51
- # Matches the exact block header layout and category color badge styling
52
  outfit_html = "".join([
53
  f'''
54
  <div class="product-card">
@@ -59,7 +58,7 @@ def analyze_and_recommend(image, skin, hair, eye, choice_method):
59
  <span class="prod-cat">{item['category']}</span>
60
  <p class="prod-title">{item['name']}</p>
61
  <span class="prod-brand">{item['brand']}</span>
62
- <a href="{item['url']}" target="_top" rel="noopener noreferrer" class="shop-btn">Shop ↗</a>
63
  </div>
64
  </div>
65
  ''' for item in look_items
@@ -93,106 +92,4 @@ def analyze_and_recommend(image, skin, hair, eye, choice_method):
93
  lookmatch_css = """
94
  body, .gradio-container { background-color: #F8F5F5 !important; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
95
  .gradio-container { max-width: 850px !important; margin: 0 auto !important; padding-top: 20px !important; }
96
- .center-text { text-align: center; }
97
-
98
- /* Header Elements */
99
- .prod-cat { font-size: 11px; font-weight: 700; color: #D2527F; letter-spacing: 1.5px; text-transform: uppercase; }
100
- .title-main { font-size: 42px; font-weight: 800; color: #111111; margin-bottom: 2px; letter-spacing: -1px; }
101
- .subtitle-main { font-size: 15px; color: #888888; margin-bottom: 30px; }
102
- h3 { font-size: 12px; font-weight: 700; color: #A4A1A1; letter-spacing: 1px; margin-top: 0; margin-bottom: 16px; }
103
-
104
- /* Input field components visibility fix */
105
- input, select, .secondary, .wrap, .slots, .single-select, .select-wrap {
106
- color: #111111 !important;
107
- background-color: #FFFFFF !important;
108
- border: 1px solid #E2DFDA !important;
109
- }
110
- div.form { background: transparent !important; border: none !important; box-shadow: none !important; }
111
-
112
- /* Original Split Box Design */
113
- .section-split { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-top: 24px; }
114
- @media (max-width: 768px) { .section-split { grid-template-columns: 1fr; } }
115
- .results-box { background: #FFFFFF; border-radius: 16px; padding: 24px; border: 1px solid #EFECE8; }
116
- .swatch-grid { display: flex; gap: 20px; justify-content: flex-start; }
117
- .swatch-card { text-align: center; font-size: 12px; color: #666; width: 64px; }
118
- .color-bubble { width: 48px; height: 48px; border-radius: 50%; margin: 0 auto 8px auto; border: 1px solid rgba(0,0,0,0.05); }
119
- .tip-text { font-size: 16px; color: #222; line-height: 1.5; margin: 0; }
120
-
121
- /* Six-Card Layout Grid matching original layout */
122
- .outfit-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 20px; }
123
- @media (max-width: 768px) { .outfit-grid { grid-template-columns: repeat(2, 1fr); } }
124
- @media (max-width: 480px) { .outfit-grid { grid-template-columns: 1fr; } }
125
-
126
- /* Replica Product Cards */
127
- .product-card { background: #FFFFFF; border: 1px solid #EFECE8; border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 4px 12px rgba(0,0,0,0.01); }
128
- .card-color-header { width: 100%; height: 95px; display: flex; align-items: center; justify-content: center; }
129
- .prod-bubble { width: 46px; height: 46px; border-radius: 50%; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
130
- .prod-meta { padding: 20px; display: flex; flex-direction: column; align-items: flex-start; text-align: left; }
131
- .prod-cat { font-size: 11px; font-weight: 700; color: #D2527F; letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 4px; }
132
- .prod-title { font-size: 16px; font-weight: 700; color: #111111; margin: 0 0 4px 0; line-height: 1.3; min-height: 42px; display: flex; align-items: center; }
133
- .prod-brand { font-size: 14px; color: #999999; margin-bottom: 16px; display: block; }
134
-
135
- /* Replica Shop Action Buttons */
136
- .shop-btn { display: block; width: 100%; background: #161617; color: #FFFFFF !important; text-align: center; padding: 12px 0; border-radius: 8px; font-size: 14px; font-weight: 700; text-decoration: none !important; letter-spacing: 0.5px; }
137
- .shop-btn:hover { background: #2D2D2F; }
138
- .primary-action-btn { background: #161617 !important; color: #FFFFFF !important; border: none !important; border-radius: 8px !important; font-weight: 700 !important; font-size: 15px !important; padding: 12px 0 !important; text-transform: uppercase; margin-top: 10px; }
139
- .pill-container button { background: #FFFFFF !important; border: 1px solid #E3DFDA !important; border-radius: 4px !important; font-size: 11px !important; font-weight: 700 !important; color: #555555 !important; text-transform: uppercase; letter-spacing: 0.5px; }
140
- .footer-note { font-size: 13px; color: #A0A0A0; text-align: center; margin-top: 20px; margin-bottom: 30px; }
141
- """
142
-
143
- # ==========================================
144
- # 3. INTERFACE BUILD
145
- # ==========================================
146
- with gr.Blocks(css=lookmatch_css) as demo:
147
-
148
- with gr.Group(elem_classes="center-text"):
149
- gr.Markdown("PERSONAL COLOR STYLING", show_label=False)
150
- gr.Markdown("# LookMatch", elem_classes="title-main")
151
- gr.Markdown("Discover your perfect color palette and outfit", elem_classes="subtitle-main")
152
-
153
- choice_method = gr.Radio(
154
- ["Upload a photo", "Choose manually"],
155
- value="Upload a photo",
156
- show_label=False,
157
- interactive=True
158
- )
159
-
160
- with gr.Row():
161
- with gr.Column() as upload_col:
162
- image_input = gr.Image(label="Upload your photo — Gemini AI will detect your features", type="pil")
163
-
164
- with gr.Column(visible=False) as manual_col:
165
- skin_dropdown = gr.Dropdown(["Fair", "Light", "Medium", "Olive", "Tan", "Deep"], value="Light", label="Skin tone")
166
- hair_dropdown = gr.Dropdown(["Blonde", "Auburn/Red", "Brunette", "Black", "Grey/White"], value="Black", label="Hair color")
167
- eye_dropdown = gr.Dropdown(["Blue", "Green", "Hazel", "Brown", "Dark brown/Black"], value="Brown", label="Eye color")
168
-
169
- submit_btn = gr.Button("Get my look ✨", elem_classes="primary-action-btn")
170
-
171
- with gr.Column(visible=False) as output_dashboard:
172
- gr.Markdown("### YOUR FEATURES")
173
- with gr.Row(elem_classes="pill-container"):
174
- skin_tag = gr.Button(value="Light", size="sm")
175
- hair_tag = gr.Button(value="Black", size="sm")
176
- eye_tag = gr.Button(value="Brown", size="sm")
177
-
178
- palette_output = gr.HTML()
179
-
180
- gr.Markdown("### OUTFIT PICKS")
181
- outfit_output = gr.HTML(elem_classes="outfit-grid")
182
- gr.Markdown("Links open Google Shopping — right-click → Open in new tab", elem_classes="footer-note")
183
-
184
- def toggle_input_ui(choice):
185
- if choice == "Choose manually":
186
- return gr.update(visible=False), gr.update(visible=True)
187
- return gr.update(visible=True), gr.update(visible=False)
188
-
189
- choice_method.change(toggle_input_ui, inputs=choice_method, outputs=[upload_col, manual_col])
190
-
191
- submit_btn.click(
192
- fn=analyze_and_recommend,
193
- inputs=[image_input, skin_dropdown, hair_dropdown, eye_dropdown, choice_method],
194
- outputs=[skin_tag, hair_tag, eye_tag, palette_output, outfit_output, output_dashboard]
195
- )
196
-
197
- if __name__ == "__main__":
198
- demo.launch()
 
20
  }
21
  }
22
 
 
23
  RECOMMENDED_LOOKS = {
24
  "Light-Black-Brown": [
25
  {"category": "TOP", "name": "Rust Wrap Blouse", "brand": "SHEIN", "hex": "#C64614", "bg": "#F5E6E1", "url": "https://www.shein.com"},
 
47
  for s in palette["swatches"]
48
  ])
49
 
50
+ # תיקון: שימוש ב-target="_blank" לפתיחה חלקה של הקישורים בכרטיסייה חדשה
51
  outfit_html = "".join([
52
  f'''
53
  <div class="product-card">
 
58
  <span class="prod-cat">{item['category']}</span>
59
  <p class="prod-title">{item['name']}</p>
60
  <span class="prod-brand">{item['brand']}</span>
61
+ <a href="{item['url']}" target="_blank" rel="noopener noreferrer" class="shop-btn">Shop ↗</a>
62
  </div>
63
  </div>
64
  ''' for item in look_items
 
92
  lookmatch_css = """
93
  body, .gradio-container { background-color: #F8F5F5 !important; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
94
  .gradio-container { max-width: 850px !important; margin: 0 auto !important; padding-top: 20px !important; }
95
+ .center-text { text-align: center