Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions computer_vision/image_annotation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# image annotation
import supervision as sv
from ultralytics import YOLO
import cv2

Check failure on line 4 in computer_vision/image_annotation.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

computer_vision/image_annotation.py:2:1: I001 Import block is un-sorted or un-formatted

# 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

Check failure on line 27 in computer_vision/image_annotation.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (B018)

computer_vision/image_annotation.py:27:1: B018 Found useless expression. Either assign it to a variable or remove it.
Loading