We write your reusable computer vision tools. ๐
MIT License
Bot releases are hidden (Show)
Published by SkalskiP over 1 year ago
Dataset
support and ability to save Detections
in Pascal VOC XML format. (https://github.com/roboflow/supervision/pull/71)mask_to_polygons
, filter_polygons_by_area
, polygon_to_xyxy
and approximate_polygon
utilities. (https://github.com/roboflow/supervision/pull/71)Dataset
. (https://github.com/roboflow/supervision/pull/72)Detections
attributes to make it consistent with order of objects in __iter__
tuple. (https://github.com/roboflow/supervision/pull/70)generate_2d_mask
to polygon_to_mask
. (https://github.com/roboflow/supervision/pull/71)Published by SkalskiP over 1 year ago
LineZone.trigger
function expects 4 values instead of 5 (https://github.com/roboflow/supervision/pull/63)Published by SkalskiP over 1 year ago
Detections.__getitem__
method did not return mask for selected item.Detections.area
crashed for mask detections.Published by SkalskiP over 1 year ago
Detections.mask
to enable segmentation support. (https://github.com/roboflow/supervision/pull/58)MaskAnnotator
to allow easy Detections.mask
annotation. (https://github.com/roboflow/supervision/pull/58)Detections.from_sam
to enable native Segment Anything Model (SAM) support. (https://github.com/roboflow/supervision/pull/58)Detections.area
behaviour to work not only with boxes but also with masks. (https://github.com/roboflow/supervision/pull/58)Published by SkalskiP over 1 year ago
Detections.empty
to allow easy creation of empty Detections
objects. (https://github.com/roboflow/supervision/discussions/48)Detections.from_roboflow
to allow easy creation of Detections
objects from Roboflow API inference results. (https://github.com/roboflow/supervision/pull/56)plot_images_grid
to allow easy plotting of multiple images on single plot. (https://github.com/roboflow/supervision/pull/56)detections_to_voc_xml
method. (https://github.com/roboflow/supervision/pull/56)show_frame_in_notebook
refactored and renamed to plot_image
. (https://github.com/roboflow/supervision/pull/56)Published by SkalskiP over 1 year ago
class_id
in sv.Detections
(https://github.com/roboflow/supervision/pull/50) to make it more flexiblePublished by SkalskiP over 1 year ago
Detections.wth_nms
support class agnostic and non-class agnostic case (https://github.com/roboflow/supervision/pull/36)PolygonZone
throws an exception when the object touches the bottom edge of the image (https://github.com/roboflow/supervision/issues/41)Detections.wth_nms
method throws an exception when Detections
is empty (https://github.com/roboflow/supervision/issues/42)Published by SkalskiP over 1 year ago
New methods in sv.Detections
API:
from_transformers
- convert Object Detection ๐ค Transformer result into sv.Detections
from_detectron2
- convert Detectron2 result into sv.Detections
from_coco_annotations
- convert COCO annotation into sv.Detections
area
- dynamically calculated property storing bbox areawith_nms
- initial implementation (only class agnostic) of sv.Detections
NMSsv.Detections.confidence
field Optional
.Published by capjamesg over 1 year ago
PolygonZone
and PolygonZoneAnnotator
๐ฅimport numpy as np
import supervision as sv
from ultralytics import YOLO
# initiate polygon zone
polygon = np.array([
[1900, 1250],
[2350, 1250],
[3500, 2160],
[1250, 2160]
])
video_info = sv.VideoInfo.from_video_path(MALL_VIDEO_PATH)
zone = sv.PolygonZone(polygon=polygon, frame_resolution_wh=video_info.resolution_wh)
# initiate annotators
box_annotator = sv.BoxAnnotator(thickness=4, text_thickness=4, text_scale=2)
zone_annotator = sv.PolygonZoneAnnotator(zone=zone, color=sv.Color.white(), thickness=6, text_thickness=6, text_scale=4)
# extract video frame
generator = sv.get_video_frames_generator(MALL_VIDEO_PATH)
iterator = iter(generator)
frame = next(iterator)
# detect
model = YOLO('yolov8s.pt')
results = model(frame, imgsz=1280)[0]
detections = sv.Detections.from_yolov8(results)
detections = detections[detections.class_id == 0]
zone.trigger(detections=detections)
# annotate
box_annotator = sv.BoxAnnotator(thickness=4, text_thickness=4, text_scale=2)
labels = [f"{model.names[class_id]} {confidence:0.2f}" for _, confidence, class_id, _ in detections]
frame = box_annotator.annotate(scene=frame, detections=detections, labels=labels)
frame = zone_annotator.annotate(scene=frame)
vs.Detections
filtering with pandas-like API.detections = detections[(detections.class_id == 0) & (detections.confidence > 0.5)]
YOLOv5
and YOLOv8
models.import torch
import supervision as sv
model = torch.hub.load('ultralytics/yolov5', 'yolov5x6')
results = model(frame, size=1280)
detections = sv.Detections.from_yolov5(results)
from ultralytics import YOLO
import supervision as sv
model = YOLO('yolov8s.pt')
results = model(frame, imgsz=1280)[0]
detections = sv.Detections.from_yolov8(results)
supervision.get_polygon_center
function - takes in a polygon as a 2-dimensional numpy.ndarray
and returns the center of the polygon as a Point objectsupervision.draw_polygon
function - draw a polygon on a scenesupervision.draw_text
function - draw a text on a scenesupervision.ColorPalette.default()
- class method - to generate default ColorPalette
supervision.generate_2d_mask
function - generate a 2D mask from a polygonsupervision.PolygonZone
class - to define polygon zones and validate if supervision.Detections
are in the zonesupervision.PolygonZoneAnnotator
class - to draw supervision.PolygonZone
on scene๐ฑ Changed
VideoInfo
API - change the property name resolution
-> resolution_wh
to make it more descriptive; convert VideoInfo
to dataclass
process_frame
API - change argument name frame
-> scene
to make it consistent with other classes and methodsLineCounter
API - rename class LineCounter
-> LineZone
to make it consistent with PolygonZone
LineCounterAnnotator
API - rename class LineCounterAnnotator
-> LineZoneAnnotator
Published by SkalskiP almost 2 years ago
DEFAULT_COLOR_PALETTE
, Color
, and ColorPalette
classesPoint
, Vector
, and Rect
classesVideoInfo
and VideoSink
classes as well as get_video_frames_generator
show_frame_in_notebook
utildraw_line
, draw_rectangle
, draw_filled_rectangle
utils addedDetections
and BoxAnnotator
addedLineCounter
and LineCounterAnnotator
classes@SkalskiP