Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -319,13 +319,28 @@ def analyze_outfit(input_img):
|
|
| 319 |
percentage_score = max(0, final_score * 100)
|
| 320 |
percentage_score_str = f"{percentage_score:.0f}%"""
|
| 321 |
|
| 322 |
-
|
| 323 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
|
| 325 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 326 |
category_key = 'drippy'
|
| 327 |
score_label = "Drip Score"
|
| 328 |
-
elif
|
| 329 |
category_key = 'mid'
|
| 330 |
score_label = "Mid Score"
|
| 331 |
else:
|
|
@@ -333,7 +348,8 @@ def analyze_outfit(input_img):
|
|
| 333 |
score_label = "Trash Score"
|
| 334 |
|
| 335 |
category_label = CATEGORY_LABEL_MAP[category_key]
|
| 336 |
-
percentage_score_str = f"{
|
|
|
|
| 337 |
|
| 338 |
|
| 339 |
print(f"Style analysis: Category={category_label}, Score = {score_label}={percentage_score_str} (Raw Score: {final_score:.4f})")
|
|
|
|
| 319 |
percentage_score = max(0, final_score * 100)
|
| 320 |
percentage_score_str = f"{percentage_score:.0f}%"""
|
| 321 |
|
| 322 |
+
# Calculate average probabilities for each category
|
| 323 |
+
drip_score = np.mean(all_probs[0 : drip_len])
|
| 324 |
+
mid_score = np.mean(all_probs[drip_len : drip_len + mid_len])
|
| 325 |
+
not_score = np.mean(all_probs[drip_len + mid_len : style_prompts_end_index])
|
| 326 |
+
|
| 327 |
+
# Use the raw probabilities to compute weighted score
|
| 328 |
+
# You can think of this like a 100-point rubric
|
| 329 |
+
# Drip contributes 100%, Mid contributes 66%, Trash contributes 33%
|
| 330 |
+
final_score = (
|
| 331 |
+
drip_score * 100 +
|
| 332 |
+
mid_score * 66 +
|
| 333 |
+
not_score * 33
|
| 334 |
+
)
|
| 335 |
|
| 336 |
+
# Clip the score between 0 and 100 for safety
|
| 337 |
+
final_score = min(max(final_score, 0), 100)
|
| 338 |
+
|
| 339 |
+
# Assign category based on final_score ranges
|
| 340 |
+
if final_score >= 75:
|
| 341 |
category_key = 'drippy'
|
| 342 |
score_label = "Drip Score"
|
| 343 |
+
elif final_score >= 40:
|
| 344 |
category_key = 'mid'
|
| 345 |
score_label = "Mid Score"
|
| 346 |
else:
|
|
|
|
| 348 |
score_label = "Trash Score"
|
| 349 |
|
| 350 |
category_label = CATEGORY_LABEL_MAP[category_key]
|
| 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})")
|