From 26af9b51ff09d536a55eb6e392eebba0a06eacbf Mon Sep 17 00:00:00 2001 From: Ifeanyi Idiaye <72707830+Ifeanyi55@users.noreply.github.com> Date: Wed, 8 Oct 2025 17:27:52 +0000 Subject: [PATCH] Created image_annotation.py --- computer_vision/image_annotation.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 computer_vision/image_annotation.py diff --git a/computer_vision/image_annotation.py b/computer_vision/image_annotation.py new file mode 100644 index 000000000000..ee7c36eeed12 --- /dev/null +++ b/computer_vision/image_annotation.py @@ -0,0 +1,27 @@ +# image annotation +import supervision as sv +from ultralytics import YOLO +import cv2 + +# load the input image +image = cv2.imread("image file path") + +# load pre-trained vision model +model = YOLO("yolo12s.pt") + +# run object detection on the image +result = model(image)[0] + +# convert YOLO output to a Supervision-compatible detections format +detections = sv.Detections.from_ultralytics(result) + +# initialize a box annotator for drawing detection bounding boxes +box_annotator = sv.BoxAnnotator() + +# annotate image with detected objects +annotated_frame = box_annotator.annotate( + scene=image.copy(), + detections=detections) + +# view annotated image +annotated_frame