We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 788d95b commit 26af9b5Copy full SHA for 26af9b5
computer_vision/image_annotation.py
@@ -0,0 +1,27 @@
1
+# image annotation
2
+import supervision as sv
3
+from ultralytics import YOLO
4
+import cv2
5
+
6
+# load the input image
7
+image = cv2.imread("image file path")
8
9
+# load pre-trained vision model
10
+model = YOLO("yolo12s.pt")
11
12
+# run object detection on the image
13
+result = model(image)[0]
14
15
+# convert YOLO output to a Supervision-compatible detections format
16
+detections = sv.Detections.from_ultralytics(result)
17
18
+# initialize a box annotator for drawing detection bounding boxes
19
+box_annotator = sv.BoxAnnotator()
20
21
+# annotate image with detected objects
22
+annotated_frame = box_annotator.annotate(
23
+ scene=image.copy(),
24
+ detections=detections)
25
26
+# view annotated image
27
+annotated_frame
0 commit comments