CJR61 Claude Sonnet 4.6 commited on
Commit
b03f9b1
·
1 Parent(s): b3857da

Remove LOW_CONF block: in-range images should always be classified

Browse files

Images passing the similarity gate (is_in_criteria=True) are already
confirmed as in-distribution. Low model confidence in those cases just
means borderline bacteria/virus — still a valid classification.

Only keep HIGH_CONF bypass (>= 0.85) to fix high-confidence images
being wrongly blocked by sim gate (e.g. organ specimens on black bg).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app/main.py +3 -7
app/main.py CHANGED
@@ -97,17 +97,13 @@ async def predict(file: UploadFile = File(...)):
97
  # 所屬類別機率(bacteria prob 直接用;virus prob = 1 - bacteria prob)
98
  class_prob = probability if probability > 0.5 else round(1 - probability, 2)
99
 
100
- # 三區間決策
101
- # ≥ HIGH_CONF:高信心 → 直接分類,跳過 similarity gate(解決非典型拍攝角度被誤擋)
102
- # LOW_CONF ~ HIGH_CONF:中信心 → 需通過 similarity gate(原本邏輯)
103
- # < LOW_CONF:低信心 → None(不夠確定,不管 similarity 如何)
104
  HIGH_CONF = 0.85
105
- LOW_CONF = 0.60
106
 
107
  if class_prob >= HIGH_CONF:
108
  is_in_criteria = True # bypass sim gate
109
- elif class_prob < LOW_CONF:
110
- is_in_criteria = False # 低信心直接 None
111
 
112
  if not is_in_criteria:
113
  prediction = "None"
 
97
  # 所屬類別機率(bacteria prob 直接用;virus prob = 1 - bacteria prob)
98
  class_prob = probability if probability > 0.5 else round(1 - probability, 2)
99
 
100
+ # 高信心 bypass:class_prob >= HIGH_CONF 時直接分類,跳過 similarity gate
101
+ # 解決非典型拍攝角度(如臟器黑底標本)被 sim gate 誤擋的問題
102
+ # 其餘情況維持原本 similarity gate 判斷
 
103
  HIGH_CONF = 0.85
 
104
 
105
  if class_prob >= HIGH_CONF:
106
  is_in_criteria = True # bypass sim gate
 
 
107
 
108
  if not is_in_criteria:
109
  prediction = "None"