Revrse commited on
Commit
06544d2
·
verified ·
1 Parent(s): 691026e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -58,10 +58,15 @@ def detect_objects(image, target_class, confidence_threshold, hf_token=None):
58
  results = object_detector.detect(image, hf_token)
59
 
60
  # Filter results for target class
 
61
  target_detections = []
62
  for detection in results:
63
- if (detection['label'].lower() == target_class.lower() and
64
- detection['score'] > confidence_threshold):
 
 
 
 
65
  target_detections.append(detection)
66
 
67
  return target_detections
 
58
  results = object_detector.detect(image, hf_token)
59
 
60
  # Filter results for target class
61
+
62
  target_detections = []
63
  for detection in results:
64
+ label = detection.get('label')
65
+ if (
66
+ label is not None and
67
+ label.lower() == target_class.lower() and
68
+ detection['score'] > confidence_threshold
69
+ ):
70
  target_detections.append(detection)
71
 
72
  return target_detections