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: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,12 @@ module = [
"tests.*",
"examples.*",
# TODO: fix type errors in the following modules
"supervision.detection.core",
"supervision.detection.line_zone",
"supervision.detection.tools.csv_sink",
"supervision.detection.tools.inference_slicer",
"supervision.detection.tools.json_sink",
"supervision.detection.tools.polygon_zone",
"supervision.detection.tools.smoother",
"supervision.detection.tools.transformers",
"supervision.detection.vlm",
"supervision.key_points.skeletons",
"supervision.metrics.utils.utils",
]
Expand Down
5 changes: 5 additions & 0 deletions src/supervision/dataset/formats/pascal_voc.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ class ids in the Detections object.
for xyxy, mask, _, class_id, _, _ in detections:
if class_id is None:
raise ValueError("Detections must include class_id for Pascal VOC export.")
if not isinstance(class_id, (int, np.integer)):
raise ValueError(
f"Detections class_id must be an integer for Pascal VOC export, "
f"got {type(class_id)!r}."
)
name = classes[class_id]
if mask is not None:
polygons = approximate_mask_with_polygons(
Expand Down
10 changes: 8 additions & 2 deletions src/supervision/dataset/formats/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ def detections_to_yolo_annotations(
for xyxy, mask, _, class_id, _, _ in detections:
if class_id is None:
raise ValueError("Class ID is required for YOLO annotations.")
if not isinstance(class_id, (int, np.integer)):
raise ValueError(
f"Detections class_id must be an integer for YOLO export, "
f"got {type(class_id)!r}."
)
class_id_int = int(class_id)

if mask is not None:
polygons = approximate_mask_with_polygons(
Expand All @@ -258,14 +264,14 @@ def detections_to_yolo_annotations(
xyxy = polygon_to_xyxy(polygon=polygon)
next_object = object_to_yolo(
xyxy=xyxy,
class_id=class_id,
class_id=class_id_int,
image_shape=image_shape,
polygon=polygon,
)
annotation.append(next_object)
else:
next_object = object_to_yolo(
xyxy=xyxy, class_id=class_id, image_shape=image_shape
xyxy=xyxy, class_id=class_id_int, image_shape=image_shape
)
annotation.append(next_object)
return annotation
Expand Down
Loading
Loading