Closed Jarradmorden closed 2 weeks ago
Hi @Jarradmorden 👋
The supervision version there is indeed very old. Here's how you'd use the annotators right now:
mask_annotator = sv.MaskAnnotator()
box_annotator = sv.BoxAnnotator()
label_annotator = sv.LabelAnnotator()
images = []
for image_name, image, annotations in dataset:
annotated_image = image.copy()
annotated_image = mask_annotator.annotate(
scene=annotated_image,
detections=annotations)
annotated_image = box_annotator.annotate(
scene=annotated_image,
detections=annotations)
annotated_image = label_annotator.annotate(
scene=annotated_image,
detections=annotations,
)
images.append(annotated_image)
The LabelAnnotator.annotate()
does accept a labels
parameter, but you probably won't need it.
Converting to Q&A since this is not a bug
Search before asking
Bug
labels or label isn't an existing parameter for box_annotate(), what do we replace this with? is it needed I just removed it?
Notebook = https://github.com/roboflow/notebooks/blob/main/notebooks/how-to-auto-train-yolov8-model-with-autodistill.ipynb
box_annotator = sv.BoxAnnotator() image = cv2.imread(f"C:/Users/jmorde02/DATA/2024-10-18_15-13-59\sample\left_3070_2024-10-18 15-17-30.481540.png")
mask_annotator = sv.MaskAnnotator() results = base_model.predict(image)
annotated_image = mask_annotator.annotate( image.copy(), detections=results )
images = [] for image_name in image_names: image = dataset.images[image_name] annotations= dataset.annotations[image_name] labels = [ dataset.classes[class_id] for class_id in annotations.class_id] annotates_image = mask_annotator.annotate( scene=image.copy(), detections=annotations) annotates_image = box_annotator.annotate( scene=annotates_image, detections=annotations labels=labels) images.append(annotates_image)
As you can see here the options
(method) def annotate( scene: ImageType@annotate, detections: Detections, custom_color_lookup: ndarray | None = None ) -> ImageType@annotate
Environment
supervision==0.24.0 Windows 11 Python3.11 Cuda 11.8
Minimal Reproducible Example
No response
Additional
No response
Are you willing to submit a PR?