@@ -13,6 +13,18 @@ date_modified: 2026-04-22
1313
1414# Detect and Annotate
1515
16+ !!! tip "Sample Image"
17+
18+ Don't have an image? Download the one used in this tutorial:
19+
20+ ```bash
21+ wget https://media.roboflow.com/notebooks/examples/dog.jpeg
22+ ```
23+
24+ ```
25+ Then replace `<SOURCE_IMAGE_PATH>` with `"dog.jpeg"`.
26+ ```
27+
1628Supervision provides a seamless process for annotating predictions generated by various
1729object detection and segmentation models. This guide shows how to perform inference
1830with the [ Inference] ( https://github.com/roboflow/inference ) ,
@@ -37,7 +49,7 @@ To run inference, initialize your chosen model and pass the source image to its
3749 from inference import get_model
3850
3951 model = get_model(model_id="yolov8n-640")
40- image = cv2.imread("<SOURCE_IMAGE_PATH> ")
52+ image = cv2.imread("dog.jpeg ")
4153 results = model.infer(image)[0]
4254 ```
4355
@@ -48,7 +60,7 @@ To run inference, initialize your chosen model and pass the source image to its
4860 from ultralytics import YOLO
4961
5062 model = YOLO("yolov8n.pt")
51- image = cv2.imread("<SOURCE_IMAGE_PATH> ")
63+ image = cv2.imread("dog.jpeg ")
5264 results = model(image)[0]
5365 ```
5466
@@ -62,7 +74,7 @@ To run inference, initialize your chosen model and pass the source image to its
6274 processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50")
6375 model = DetrForObjectDetection.from_pretrained("facebook/detr-resnet-50")
6476
65- image = Image.open("<SOURCE_IMAGE_PATH> ")
77+ image = Image.open("dog.jpeg ")
6678 inputs = processor(images=image, return_tensors="pt")
6779
6880 with torch.no_grad():
@@ -91,7 +103,7 @@ Each supported framework has a dedicated class method on `sv.Detections` that co
91103 from inference import get_model
92104
93105 model = get_model(model_id="yolov8n-640")
94- image = cv2.imread("<SOURCE_IMAGE_PATH> ")
106+ image = cv2.imread("dog.jpeg ")
95107 results = model.infer(image)[0]
96108 detections = sv.Detections.from_inference(results)
97109 ```
@@ -106,7 +118,7 @@ Each supported framework has a dedicated class method on `sv.Detections` that co
106118 from ultralytics import YOLO
107119
108120 model = YOLO("yolov8n.pt")
109- image = cv2.imread("<SOURCE_IMAGE_PATH> ")
121+ image = cv2.imread("dog.jpeg ")
110122 results = model(image)[0]
111123 detections = sv.Detections.from_ultralytics(results)
112124 ```
@@ -124,7 +136,7 @@ Each supported framework has a dedicated class method on `sv.Detections` that co
124136 processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50")
125137 model = DetrForObjectDetection.from_pretrained("facebook/detr-resnet-50")
126138
127- image = Image.open("<SOURCE_IMAGE_PATH> ")
139+ image = Image.open("dog.jpeg ")
128140 inputs = processor(images=image, return_tensors="pt")
129141
130142 with torch.no_grad():
@@ -161,7 +173,7 @@ To draw bounding boxes and class labels on your image, create a `BoxAnnotator` a
161173 from inference import get_model
162174
163175 model = get_model(model_id="yolov8n-640")
164- image = cv2.imread("<SOURCE_IMAGE_PATH> ")
176+ image = cv2.imread("dog.jpeg ")
165177 results = model.infer(image)[0]
166178 detections = sv.Detections.from_inference(results)
167179
@@ -182,7 +194,7 @@ To draw bounding boxes and class labels on your image, create a `BoxAnnotator` a
182194 from ultralytics import YOLO
183195
184196 model = YOLO("yolov8n.pt")
185- image = cv2.imread("<SOURCE_IMAGE_PATH> ")
197+ image = cv2.imread("dog.jpeg ")
186198 results = model(image)[0]
187199 detections = sv.Detections.from_ultralytics(results)
188200
@@ -206,7 +218,7 @@ To draw bounding boxes and class labels on your image, create a `BoxAnnotator` a
206218 processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50")
207219 model = DetrForObjectDetection.from_pretrained("facebook/detr-resnet-50")
208220
209- image = Image.open("<SOURCE_IMAGE_PATH> ")
221+ image = Image.open("dog.jpeg ")
210222 inputs = processor(images=image, return_tensors="pt")
211223
212224 with torch.no_grad():
@@ -245,7 +257,7 @@ override this behavior by passing a list of custom `labels` to the `annotate` me
245257 from inference import get_model
246258
247259 model = get_model(model_id="yolov8n-640")
248- image = cv2.imread("<SOURCE_IMAGE_PATH> ")
260+ image = cv2.imread("dog.jpeg ")
249261 results = model.infer(image)[0]
250262 detections = sv.Detections.from_inference(results)
251263
@@ -272,7 +284,7 @@ override this behavior by passing a list of custom `labels` to the `annotate` me
272284 from ultralytics import YOLO
273285
274286 model = YOLO("yolov8n.pt")
275- image = cv2.imread("<SOURCE_IMAGE_PATH> ")
287+ image = cv2.imread("dog.jpeg ")
276288 results = model(image)[0]
277289 detections = sv.Detections.from_ultralytics(results)
278290
@@ -302,7 +314,7 @@ override this behavior by passing a list of custom `labels` to the `annotate` me
302314 processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50")
303315 model = DetrForObjectDetection.from_pretrained("facebook/detr-resnet-50")
304316
305- image = Image.open("<SOURCE_IMAGE_PATH> ")
317+ image = Image.open("dog.jpeg ")
306318 inputs = processor(images=image, return_tensors="pt")
307319
308320 with torch.no_grad():
@@ -349,7 +361,7 @@ that will allow you to draw masks instead of boxes.
349361 from inference import get_model
350362
351363 model = get_model(model_id="yolov8n-seg-640")
352- image = cv2.imread("<SOURCE_IMAGE_PATH> ")
364+ image = cv2.imread("dog.jpeg ")
353365 results = model.infer(image)[0]
354366 detections = sv.Detections.from_inference(results)
355367
@@ -364,6 +376,7 @@ that will allow you to draw masks instead of boxes.
364376 scene=annotated_image,
365377 detections=detections,
366378 )
379+ sv.plot_image(annotated_image)
367380 ```
368381
369382=== "Ultralytics"
@@ -374,7 +387,7 @@ that will allow you to draw masks instead of boxes.
374387 from ultralytics import YOLO
375388
376389 model = YOLO("yolov8n-seg.pt")
377- image = cv2.imread("<SOURCE_IMAGE_PATH> ")
390+ image = cv2.imread("dog.jpeg ")
378391 results = model(image)[0]
379392 detections = sv.Detections.from_ultralytics(results)
380393
@@ -402,7 +415,7 @@ that will allow you to draw masks instead of boxes.
402415 processor = DetrImageProcessor.from_pretrained("facebook/detr-resnet-50-panoptic")
403416 model = DetrForSegmentation.from_pretrained("facebook/detr-resnet-50-panoptic")
404417
405- image = Image.open("<SOURCE_IMAGE_PATH> ")
418+ image = Image.open("dog.jpeg ")
406419 inputs = processor(images=image, return_tensors="pt")
407420
408421 with torch.no_grad():
0 commit comments