Skip to content
Open
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
5 changes: 4 additions & 1 deletion src/supervision/detection/tools/csv_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"class_id",
"confidence",
"tracker_id",
"area",
]
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding area to BASE_HEADER can produce duplicate area columns when callers still pass custom_data={'area': ...} (or if detections.data contains an area key). parse_field_names() currently appends all dynamic keys without excluding base fields, so the header can contain duplicate names and the resulting CSV becomes ambiguous. Consider filtering dynamic_header to remove any keys already in BASE_HEADER (and/or treating base-field overrides as an error).

Suggested change
]
]
BASE_HEADER_SET = set(BASE_HEADER)

Copilot uses AI. Check for mistakes.


Expand All @@ -33,7 +34,7 @@ class CSVSink:
A utility class for saving detection data to a CSV file. This class is designed to
efficiently serialize detection objects into a CSV format, allowing for the
inclusion of bounding box coordinates and additional attributes like `confidence`,
`class_id`, and `tracker_id`.
`class_id`, `tracker_id`, and `area`.

!!! tip

Expand Down Expand Up @@ -117,6 +118,7 @@ def parse_detection_data(
detections: Detections, custom_data: dict[str, Any] | None = None
) -> list[dict[str, Any]]:
parsed_rows = []
areas = detections.area
for i in range(len(detections.xyxy)):
row = {
"x_min": detections.xyxy[i][0],
Expand All @@ -132,6 +134,7 @@ def parse_detection_data(
"tracker_id": ""
if detections.tracker_id is None
else str(detections.tracker_id[i]),
"area": str(areas[i]),
}

if hasattr(detections, "data"):
Expand Down
Loading