Spaces:
Paused
Paused
Ali Mohsin
commited on
Commit
·
44897d2
1
Parent(s):
6204e53
fixes
Browse files
app.py
CHANGED
|
@@ -847,6 +847,57 @@ def gradio_recommend(
|
|
| 847 |
error_msg += "Please check that files are valid image files."
|
| 848 |
return [], {"error": error_msg, "exception": str(e), "files_received": len(files)}
|
| 849 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 850 |
# Build comprehensive context with all tags
|
| 851 |
context = {
|
| 852 |
"occasion": occasion,
|
|
@@ -1267,7 +1318,7 @@ with gr.Blocks(fill_height=True, title="Dressify - Advanced Outfit Recommendatio
|
|
| 1267 |
with gr.Accordion("🎨 Style & Preference Tags (Optional)", open=False):
|
| 1268 |
with gr.Row():
|
| 1269 |
color_preference = gr.Dropdown(
|
| 1270 |
-
choices=["None", "neutral", "monochromatic", "complementary", "bold", "subtle",
|
| 1271 |
"bright", "muted", "pastel", "dark", "light", "earth_tones", "jewel_tones",
|
| 1272 |
"black_white", "navy_white", "colorful", "minimal_color"],
|
| 1273 |
value="None",
|
|
|
|
| 847 |
error_msg += "Please check that files are valid image files."
|
| 848 |
return [], {"error": error_msg, "exception": str(e), "files_received": len(files)}
|
| 849 |
|
| 850 |
+
# Tag normalization: Map frontend values to backend values
|
| 851 |
+
# This handles variations and synonyms from different frontend implementations
|
| 852 |
+
def normalize_tag_value(tag_name: str, value: str) -> str:
|
| 853 |
+
"""Normalize tag values to match backend expectations"""
|
| 854 |
+
if not value or value == "None" or value is None:
|
| 855 |
+
return None
|
| 856 |
+
|
| 857 |
+
value_lower = value.lower().strip()
|
| 858 |
+
|
| 859 |
+
# Color preference mappings
|
| 860 |
+
if tag_name == "color_preference":
|
| 861 |
+
color_mappings = {
|
| 862 |
+
"monochrome": "monochromatic", # Frontend uses "monochrome", backend uses "monochromatic"
|
| 863 |
+
"mono": "monochromatic",
|
| 864 |
+
"single_color": "monochromatic",
|
| 865 |
+
"one_color": "monochromatic",
|
| 866 |
+
}
|
| 867 |
+
return color_mappings.get(value_lower, value) # Return mapped value or original
|
| 868 |
+
|
| 869 |
+
# Fit preference mappings
|
| 870 |
+
if tag_name == "fit_preference":
|
| 871 |
+
fit_mappings = {
|
| 872 |
+
"slim": "fitted",
|
| 873 |
+
"tight_fit": "fitted",
|
| 874 |
+
"baggy": "loose",
|
| 875 |
+
"wide": "loose",
|
| 876 |
+
}
|
| 877 |
+
return fit_mappings.get(value_lower, value)
|
| 878 |
+
|
| 879 |
+
# Season mappings
|
| 880 |
+
if tag_name == "season":
|
| 881 |
+
season_mappings = {
|
| 882 |
+
"autumn": "fall", # Both are valid, but normalize to "fall"
|
| 883 |
+
}
|
| 884 |
+
return season_mappings.get(value_lower, value)
|
| 885 |
+
|
| 886 |
+
# Return original value if no mapping found
|
| 887 |
+
return value
|
| 888 |
+
|
| 889 |
+
# Normalize all tag values
|
| 890 |
+
occasion = normalize_tag_value("occasion", occasion) or occasion
|
| 891 |
+
weather = normalize_tag_value("weather", weather) or weather
|
| 892 |
+
outfit_style = normalize_tag_value("outfit_style", outfit_style) or outfit_style
|
| 893 |
+
color_preference = normalize_tag_value("color_preference", color_preference) if color_preference else None
|
| 894 |
+
fit_preference = normalize_tag_value("fit_preference", fit_preference) if fit_preference else None
|
| 895 |
+
material_preference = normalize_tag_value("material_preference", material_preference) if material_preference else None
|
| 896 |
+
season = normalize_tag_value("season", season) if season else None
|
| 897 |
+
time_of_day = normalize_tag_value("time_of_day", time_of_day) if time_of_day else None
|
| 898 |
+
budget = normalize_tag_value("budget", budget) if budget else None
|
| 899 |
+
personal_style = normalize_tag_value("personal_style", personal_style) if personal_style else None
|
| 900 |
+
|
| 901 |
# Build comprehensive context with all tags
|
| 902 |
context = {
|
| 903 |
"occasion": occasion,
|
|
|
|
| 1318 |
with gr.Accordion("🎨 Style & Preference Tags (Optional)", open=False):
|
| 1319 |
with gr.Row():
|
| 1320 |
color_preference = gr.Dropdown(
|
| 1321 |
+
choices=["None", "neutral", "monochromatic", "monochrome", "complementary", "bold", "subtle",
|
| 1322 |
"bright", "muted", "pastel", "dark", "light", "earth_tones", "jewel_tones",
|
| 1323 |
"black_white", "navy_white", "colorful", "minimal_color"],
|
| 1324 |
value="None",
|