romi2001 commited on
Commit
3b5ef65
·
verified ·
1 Parent(s): f715676

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -197,7 +197,6 @@ def faiss_filtered_search(query_emb, top_k=3, exclude_idx=None, gender=None, age
197
  if idx == -1 or (exclude_idx is not None and idx == exclude_idx):
198
  continue
199
  row = df.iloc[idx]
200
- # FIXED: Syntax correction changing '&&' to python's native 'and' operator
201
  if require_gender and gender and str(row["gender"]).lower() != str(gender).lower():
202
  continue
203
  if require_age and age_group and str(row["age_group"]).lower() != str(age_group).lower():
@@ -260,9 +259,11 @@ def generate_new_outfit_image(pil_image, row, target_gender=None):
260
  resized_face_crop = base.resize((head_w, head_h))
261
  resized_protect_img = Image.fromarray(protect.astype(np.uint8) * 255).resize((head_w, head_h), resample=Image.NEAREST)
262
 
263
- canvas = Image.new("RGB", (canvas_w, canvas_h), color=(240, 238, 235))
264
  paste_x = (canvas_w - head_w) // 2
265
  paste_y = int(canvas_h * 0.03)
 
 
266
  canvas.paste(resized_face_crop, (paste_x, paste_y))
267
 
268
  mask_arr = np.full((canvas_h, canvas_w), 255, dtype=np.uint8)
@@ -396,7 +397,7 @@ def build_features_recap_html(skin_tone, undertone, style):
396
  return f'<div style="background:#fff;border-radius:16px;padding:24px;margin-bottom:20px;border:1px solid #ECE4D6;"><div style="font-size:12px;font-weight:700;color:#D2527F;text-transform:uppercase;letter-spacing:.1em;margin-bottom:16px;">Your Selected Specifications</div>{build_feature_pills_html(SKIN_TONES, skin_tone, "Skin tone")}{build_feature_pills_html(UNDERTONES, undertone, "Undertone")}{build_feature_pills_html(STYLES, style, "Style")}</div>'
397
 
398
  # ---------------------------------------------------------------------------
399
- # PREMIUM PASTEL LUXURY CSS THEME
400
  # ---------------------------------------------------------------------------
401
  CUSTOM_CSS = """
402
  @import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Inter:wght@400;500;600;700&display=swap');
 
197
  if idx == -1 or (exclude_idx is not None and idx == exclude_idx):
198
  continue
199
  row = df.iloc[idx]
 
200
  if require_gender and gender and str(row["gender"]).lower() != str(gender).lower():
201
  continue
202
  if require_age and age_group and str(row["age_group"]).lower() != str(age_group).lower():
 
259
  resized_face_crop = base.resize((head_w, head_h))
260
  resized_protect_img = Image.fromarray(protect.astype(np.uint8) * 255).resize((head_w, head_h), resample=Image.NEAREST)
261
 
262
+ # FIX: Calculation of coordinates performed BEFORE pasting inside the canvas space
263
  paste_x = (canvas_w - head_w) // 2
264
  paste_y = int(canvas_h * 0.03)
265
+
266
+ canvas = Image.new("RGB", (canvas_w, canvas_h), color=(240, 238, 235))
267
  canvas.paste(resized_face_crop, (paste_x, paste_y))
268
 
269
  mask_arr = np.full((canvas_h, canvas_w), 255, dtype=np.uint8)
 
397
  return f'<div style="background:#fff;border-radius:16px;padding:24px;margin-bottom:20px;border:1px solid #ECE4D6;"><div style="font-size:12px;font-weight:700;color:#D2527F;text-transform:uppercase;letter-spacing:.1em;margin-bottom:16px;">Your Selected Specifications</div>{build_feature_pills_html(SKIN_TONES, skin_tone, "Skin tone")}{build_feature_pills_html(UNDERTONES, undertone, "Undertone")}{build_feature_pills_html(STYLES, style, "Style")}</div>'
398
 
399
  # ---------------------------------------------------------------------------
400
+ # FIXED GRADIO 6 COMPLIANT LUXURY THEME
401
  # ---------------------------------------------------------------------------
402
  CUSTOM_CSS = """
403
  @import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Inter:wght@400;500;600;700&display=swap');