Orkhan Hasanli commited on
Commit
5ce2fb0
·
1 Parent(s): f851934

Modified default thresholds for display and gap

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -108,7 +108,7 @@ def run_detection(image, model):
108
  return out_img, det_json
109
 
110
 
111
- def run_dfine_classify(image, refs_path, dfine_threshold, dfine_model_choice, min_display_conf=0.705, gap_threshold=0.02):
112
  """Tab 2: D-FINE first, then classify crops with Jina.
113
  Returns (group_crop_gallery, known_crop_gallery, status_message).
114
  """
@@ -232,7 +232,9 @@ with gr.Blocks(title="Small Object Detection") as app:
232
  "**D-FINE** runs first (person/car grouping), then small-object crops are classified with **Jina**. "
233
  "Choose D-FINE model size (Medium or Large). "
234
  "Uses the **refs** folder (one subfolder per class, e.g. refs/phone/, refs/cigarette/) "
235
- "with reference images."
 
 
236
  )
237
 
238
  with gr.Row():
@@ -285,7 +287,7 @@ with gr.Blocks(title="Small Object Detection") as app:
285
  threshold_slider = gr.Slider(
286
  minimum=0.0,
287
  maximum=1.0,
288
- value=0.705,
289
  step=0.005,
290
  label="Threshold (min display confidence)",
291
  )
@@ -293,9 +295,9 @@ with gr.Blocks(title="Small Object Detection") as app:
293
  gap_slider = gr.Slider(
294
  minimum=0.0,
295
  maximum=0.02,
296
- value=0.02,
297
  step=0.001,
298
- label="Gap threshold (best second-best; accept class only if gap this)",
299
  )
300
 
301
  out_gallery_dfine = gr.Gallery(
 
108
  return out_img, det_json
109
 
110
 
111
+ def run_dfine_classify(image, refs_path, dfine_threshold, dfine_model_choice, min_display_conf=0.703, gap_threshold=0.005):
112
  """Tab 2: D-FINE first, then classify crops with Jina.
113
  Returns (group_crop_gallery, known_crop_gallery, status_message).
114
  """
 
232
  "**D-FINE** runs first (person/car grouping), then small-object crops are classified with **Jina**. "
233
  "Choose D-FINE model size (Medium or Large). "
234
  "Uses the **refs** folder (one subfolder per class, e.g. refs/phone/, refs/cigarette/) "
235
+ "with reference images.\n\n"
236
+ "**Gap** = how much the top class (e.g. gun) must beat the next-best class (e.g. phone). "
237
+ "Bigger gap means the model is more sure; we only accept the label if both confidence and gap are high enough."
238
  )
239
 
240
  with gr.Row():
 
287
  threshold_slider = gr.Slider(
288
  minimum=0.0,
289
  maximum=1.0,
290
+ value=0.703,
291
  step=0.005,
292
  label="Threshold (min display confidence)",
293
  )
 
295
  gap_slider = gr.Slider(
296
  minimum=0.0,
297
  maximum=0.02,
298
+ value=0.005,
299
  step=0.001,
300
+ label="Gap: how much the top guess must beat the runner-up (higher = stricter, fewer accepted)",
301
  )
302
 
303
  out_gallery_dfine = gr.Gallery(