mubbyade commited on
Commit
bf6364f
·
verified ·
1 Parent(s): 29f7a05

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -38,13 +38,14 @@ model = load_model(MODEL_PATH, compile=False)
38
  general_embedding_model = EfficientNetB0(weights="imagenet", include_top=False, pooling="avg")
39
  ood_detector = TomatoOODDetector(model, stats_path=STATS_PATH, embedding_model=general_embedding_model)
40
 
41
- # Tightening this (0.6x) to catch a hard-case apple photo caused a real
42
- # tomato photo (pile of tomatoes, unusual composition) to get wrongly
43
- # rejected at distance 12.225 — well within what real training photos span
44
- # (up to 12.306). That's a worse trade than letting one near-identical
45
- # apple stock photo through. Reverting to the raw data-derived threshold
46
- # (margin_factor=1.15 over actual training spread) rather than the
47
- # aggressive guess.
 
48
  OOD_CONFIDENCE_THRESHOLD = 0.55
49
 
50
 
@@ -100,4 +101,4 @@ demo = gr.Interface(
100
  )
101
 
102
  if __name__ == "__main__":
103
- demo.launch(server_name="0.0.0.0", server_port=7860, show_api=False)
 
38
  general_embedding_model = EfficientNetB0(weights="imagenet", include_top=False, pooling="avg")
39
  ood_detector = TomatoOODDetector(model, stats_path=STATS_PATH, embedding_model=general_embedding_model)
40
 
41
+ # Deliberately tightened below an orange's observed distance (10.661) at the
42
+ # user's explicit request, accepting the known risk: this sits below the
43
+ # distance of at least one real tomato photo seen in testing (a pile of
44
+ # tomatoes, unusual composition, at 12.225), which was wrongly rejected at
45
+ # a similarly tight setting before. Unusual real tomato photos may now get
46
+ # rejected as "not a tomato" — this trade was made knowingly, not by default.
47
+ if ood_detector.distance_threshold is not None:
48
+ ood_detector.distance_threshold = 10.3
49
  OOD_CONFIDENCE_THRESHOLD = 0.55
50
 
51
 
 
101
  )
102
 
103
  if __name__ == "__main__":
104
+ demo.launch(server_name="0.0.0.0", server_port=7860, show_api=False)