Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -295,9 +295,6 @@ def analyze_outfit(input_img):
|
|
| 295 |
|
| 296 |
drip_len = len(style_prompts['drippy'])
|
| 297 |
mid_len = len(style_prompts['mid'])
|
| 298 |
-
drip_score = np.mean(all_probs[0 : drip_len])
|
| 299 |
-
mid_score = np.mean(all_probs[drip_len : drip_len + mid_len])
|
| 300 |
-
not_score = np.mean(all_probs[drip_len + mid_len : style_prompts_end_index])
|
| 301 |
|
| 302 |
# Determine overall style category AND DEFINE score_label
|
| 303 |
score_label = "Style Score" # Initialize with a default/fallback
|
|
@@ -334,9 +331,20 @@ def analyze_outfit(input_img):
|
|
| 334 |
)
|
| 335 |
|
| 336 |
# Clip the score between 0 and 100 for safety
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
final_score = min(max(final_score, 0), 100)
|
| 338 |
|
| 339 |
-
#
|
| 340 |
if final_score >= 75:
|
| 341 |
category_key = 'drippy'
|
| 342 |
score_label = "Drip Score"
|
|
@@ -351,6 +359,7 @@ def analyze_outfit(input_img):
|
|
| 351 |
percentage_score_str = f"{final_score:.0f}%"
|
| 352 |
|
| 353 |
|
|
|
|
| 354 |
|
| 355 |
print(f"Style analysis: Category={category_label}, Score = {score_label}={percentage_score_str} (Raw Score: {final_score:.4f})")
|
| 356 |
|
|
@@ -417,7 +426,7 @@ def analyze_outfit(input_img):
|
|
| 417 |
category_html = f"""
|
| 418 |
<div class='results-container'>
|
| 419 |
<h2 class='result-category'>RATING: {category_label.upper()}</h2>
|
| 420 |
-
<p class='result-score'>{score_label}: {
|
| 421 |
</div>
|
| 422 |
"""
|
| 423 |
return category_html, tts_path, response_text
|
|
|
|
| 295 |
|
| 296 |
drip_len = len(style_prompts['drippy'])
|
| 297 |
mid_len = len(style_prompts['mid'])
|
|
|
|
|
|
|
|
|
|
| 298 |
|
| 299 |
# Determine overall style category AND DEFINE score_label
|
| 300 |
score_label = "Style Score" # Initialize with a default/fallback
|
|
|
|
| 331 |
)
|
| 332 |
|
| 333 |
# Clip the score between 0 and 100 for safety
|
| 334 |
+
# Weighted score formula:
|
| 335 |
+
# - Drip is worth full points (x1)
|
| 336 |
+
# - Mid is worth 2/3 points (~66%)
|
| 337 |
+
# - Trash is worth 1/3 points (~33%)
|
| 338 |
+
|
| 339 |
+
final_score = (drip_score * 1.0) + (mid_score * 0.66) + (not_score * 0.33)
|
| 340 |
+
|
| 341 |
+
# Now map it to a 0–100 scale
|
| 342 |
+
final_score = final_score * 100
|
| 343 |
+
|
| 344 |
+
# Clip it just in case (though it shouldn't exceed 100 now)
|
| 345 |
final_score = min(max(final_score, 0), 100)
|
| 346 |
|
| 347 |
+
# Now classify the category based on the final_score
|
| 348 |
if final_score >= 75:
|
| 349 |
category_key = 'drippy'
|
| 350 |
score_label = "Drip Score"
|
|
|
|
| 359 |
percentage_score_str = f"{final_score:.0f}%"
|
| 360 |
|
| 361 |
|
| 362 |
+
|
| 363 |
|
| 364 |
print(f"Style analysis: Category={category_label}, Score = {score_label}={percentage_score_str} (Raw Score: {final_score:.4f})")
|
| 365 |
|
|
|
|
| 426 |
category_html = f"""
|
| 427 |
<div class='results-container'>
|
| 428 |
<h2 class='result-category'>RATING: {category_label.upper()}</h2>
|
| 429 |
+
<p class='result-score'>{score_label}: {percentage_score_str}</p>
|
| 430 |
</div>
|
| 431 |
"""
|
| 432 |
return category_html, tts_path, response_text
|