Spaces:
Running
Running
Update app/services/classifier.py
Browse files- app/services/classifier.py +19 -1
app/services/classifier.py
CHANGED
|
@@ -71,6 +71,13 @@ NOT_GAME_LABELS = [
|
|
| 71 |
"image editing app with filters brightness and contrast sliders",
|
| 72 |
"a graphic design application with artboard and shapes",
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
# Productivity
|
| 75 |
"Microsoft Excel spreadsheet with rows columns and cell data",
|
| 76 |
"Google Sheets or table with numerical data and formulas",
|
|
@@ -452,11 +459,22 @@ def _classify_game_with_zero_shot(file_path: str, suspected_game: bool) -> dict[
|
|
| 452 |
second_game_score = score
|
| 453 |
|
| 454 |
score_gap = top_game_score - second_game_score if top_game_score > 0 else 1.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 455 |
is_ambiguous = (
|
| 456 |
(game_score < GAME_ZERO_SHOT_GAME_THRESHOLD and
|
| 457 |
score_gap < GAME_ZERO_SHOT_AMBIGUOUS_THRESHOLD) or
|
| 458 |
(game_score >= 0.15 and game_score < GAME_ZERO_SHOT_GAME_THRESHOLD and
|
| 459 |
-
float(top["score"]) < GAME_ZERO_SHOT_NOT_GAME_THRESHOLD)
|
|
|
|
| 460 |
)
|
| 461 |
|
| 462 |
# Clear game: high confidence
|
|
|
|
| 71 |
"image editing app with filters brightness and contrast sliders",
|
| 72 |
"a graphic design application with artboard and shapes",
|
| 73 |
|
| 74 |
+
# Presentation / Slide (FIX for the "NHÓM ZOO" case)
|
| 75 |
+
"a presentation slide with text and circular icons",
|
| 76 |
+
"a PowerPoint or Keynote slide with a green abstract background",
|
| 77 |
+
"a graphic design featuring cartoon characters and memes",
|
| 78 |
+
"a digital poster or infographic with text and illustrations",
|
| 79 |
+
"a school project presentation or slide deck",
|
| 80 |
+
|
| 81 |
# Productivity
|
| 82 |
"Microsoft Excel spreadsheet with rows columns and cell data",
|
| 83 |
"Google Sheets or table with numerical data and formulas",
|
|
|
|
| 459 |
second_game_score = score
|
| 460 |
|
| 461 |
score_gap = top_game_score - second_game_score if top_game_score > 0 else 1.0
|
| 462 |
+
# NEW: Find top NOT-GAME score to compare
|
| 463 |
+
not_game_score = 0.0
|
| 464 |
+
for i, score in enumerate(probs):
|
| 465 |
+
if i not in GAME_ZERO_SHOT_GAME_LABEL_INDICES:
|
| 466 |
+
if score > not_game_score:
|
| 467 |
+
not_game_score = score
|
| 468 |
+
|
| 469 |
+
# Logic kích hoạt Qwen nhạy bén hơn:
|
| 470 |
+
# 1. Trường hợp bình thường: điểm thấp hoặc gap hẹp
|
| 471 |
+
# 2. Trường hợp đặc biệt: điểm game cao nhưng điểm design/not-game cũng "nhô" lên (0.25 - 0.4)
|
| 472 |
is_ambiguous = (
|
| 473 |
(game_score < GAME_ZERO_SHOT_GAME_THRESHOLD and
|
| 474 |
score_gap < GAME_ZERO_SHOT_AMBIGUOUS_THRESHOLD) or
|
| 475 |
(game_score >= 0.15 and game_score < GAME_ZERO_SHOT_GAME_THRESHOLD and
|
| 476 |
+
float(top["score"]) < GAME_ZERO_SHOT_NOT_GAME_THRESHOLD) or
|
| 477 |
+
(game_score >= GAME_ZERO_SHOT_GAME_THRESHOLD and not_game_score > 0.25) # Cạnh tranh cao
|
| 478 |
)
|
| 479 |
|
| 480 |
# Clear game: high confidence
|