Panagiota Moraiti commited on
Commit
289871b
·
1 Parent(s): e0be156

Modify plotting scale

Browse files
scripts/plot_bboxes_save_images_and_yolo_predictions.py CHANGED
@@ -63,13 +63,18 @@ def annotate_image(image, detections, class_names):
63
  class_id = detections.class_id[i]
64
  conf = detections.confidence[i]
65
  label = f"{class_names[class_id]} {conf:.2f}"
 
66
 
67
  # Draw box
68
- box_annotator = sv.BoxAnnotator(thickness=6)
 
 
 
 
69
  image = box_annotator.annotate(scene=image, detections=detections[i:i+1])
70
 
71
  # Draw label
72
- label_annotator = sv.LabelAnnotator(text_scale=2.0, text_thickness=4)
73
  image = label_annotator.annotate(scene=image, detections=detections[i:i+1], labels=[label])
74
 
75
  return image
 
63
  class_id = detections.class_id[i]
64
  conf = detections.confidence[i]
65
  label = f"{class_names[class_id]} {conf:.2f}"
66
+ _, width = image.shape[:2]
67
 
68
  # Draw box
69
+ text_size = 2.0*width/1024
70
+ box_thickness = int(6 * width / 1024) # scale box thickness
71
+ text_thickness = max(1, int(6 * width / 1024)) # scale text thickness, min 1
72
+
73
+ box_annotator = sv.BoxAnnotator(thickness=box_thickness)
74
  image = box_annotator.annotate(scene=image, detections=detections[i:i+1])
75
 
76
  # Draw label
77
+ label_annotator = sv.LabelAnnotator(text_scale=text_size, text_thickness=text_thickness)
78
  image = label_annotator.annotate(scene=image, detections=detections[i:i+1], labels=[label])
79
 
80
  return image