onuralpszr commited on
Commit
7439234
β€’
1 Parent(s): d14e05c

fix: 🐞 Label and Box Annotators fixed

Browse files

Signed-off-by: Onuralp SEZER <[email protected]>

Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -4,7 +4,8 @@ from ultralytics import YOLO
4
  import spaces
5
  import supervision as sv
6
 
7
- box_annotator = sv.BoxAnnotator()
 
8
 
9
  category_dict = {
10
  0: 'person', 1: 'bicycle', 2: 'car', 3: 'motorcycle', 4: 'airplane', 5: 'bus',
@@ -56,7 +57,12 @@ def LeYOLO_inference(image, model_id, image_size, conf_threshold, iou_threshold)
56
  f"{category_dict[class_id]} {confidence:.2f}"
57
  for class_id, confidence in zip(detections.class_id, detections.confidence)
58
  ]
59
- annotated_image = box_annotator.annotate(image, detections=detections, labels=labels)
 
 
 
 
 
60
 
61
  return annotated_image
62
 
 
4
  import spaces
5
  import supervision as sv
6
 
7
+ BOX_ANNOTATOR = sv.BoxAnnotator()
8
+ LABEL_ANNOTATOR = sv.LabelAnnotator()
9
 
10
  category_dict = {
11
  0: 'person', 1: 'bicycle', 2: 'car', 3: 'motorcycle', 4: 'airplane', 5: 'bus',
 
57
  f"{category_dict[class_id]} {confidence:.2f}"
58
  for class_id, confidence in zip(detections.class_id, detections.confidence)
59
  ]
60
+
61
+
62
+ annotated_image = BOX_ANNOTATOR.annotate(
63
+ scene=image, detections=detections)
64
+ annotated_image = LABEL_ANNOTATOR.annotate(
65
+ scene=annotated_image, detections=detections, labels=labels)
66
 
67
  return annotated_image
68