Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion supervision/dataset/formats/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ def yolo_annotations_to_detections(
return Detections(class_id=class_id, xyxy=xyxy, data=data)

polygons = [
(polygon * np.array(resolution_wh)).astype(int) for polygon in relative_polygon
np.round(polygon * np.array(resolution_wh, dtype=np.float32)).astype(int)
for polygon in relative_polygon
]
mask = _polygons_to_masks(polygons=polygons, resolution_wh=resolution_wh)
return Detections(class_id=class_id, xyxy=xyxy, data=data, mask=mask)
Expand Down
18 changes: 18 additions & 0 deletions test/dataset/formats/test_yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,24 @@ def test_with_mask(
),
DoesNotRaise(),
), # yolo annotation file with two lines - one box and one polygon
(
["0 0.4056 0.4078 0.5967 0.4089 0.5978 0.6012 0.4067 0.5989"],
(1000, 1000),
True,
Detections(
xyxy=np.array([[405.6, 407.8, 597.8, 601.2]], dtype=np.float32),
class_id=np.array([0], dtype=int),
mask=np.array(
[
_mock_simple_mask(
resolution_wh=(1000, 1000), box=[406, 408, 598, 601]
)
],
dtype=bool,
),
),
DoesNotRaise(),
),
],
)
def test_yolo_annotations_to_detections(
Expand Down