diff --git a/airo-dataset-tools/airo_dataset_tools/coco_tools/transform_dataset.py b/airo-dataset-tools/airo_dataset_tools/coco_tools/transform_dataset.py index 1a193f2..623f7e1 100644 --- a/airo-dataset-tools/airo_dataset_tools/coco_tools/transform_dataset.py +++ b/airo-dataset-tools/airo_dataset_tools/coco_tools/transform_dataset.py @@ -41,11 +41,23 @@ def apply_transform_to_coco_dataset( # type: ignore # noqa: C901 coco_dataset = CocoKeypointsDataset(**coco_dataset.model_dump(exclude_none=False)) transform_keypoints = all(annotation.keypoints is not None for annotation in coco_dataset.annotations) - except PydanticValidationError: + except PydanticValidationError as e: + print("not transforming keypoints due to pydantic validation error") + print(e) transform_keypoints = False + # check if bboxes and masks are present transform_bbox = all(annotation.bbox is not None for annotation in coco_dataset.annotations) transform_segmentation = all(annotation.segmentation is not None for annotation in coco_dataset.annotations) + + # check if seg masks are not empty arrays + for annotation in coco_dataset.annotations: + print(annotation.segmentation) + if isinstance(annotation.segmentation, list) and len(annotation.segmentation) == 0: + print("Empty segmentation mask found. Skipping segmentation transformation.") + transform_segmentation = False + break + print(f"Transforming keypoints = {transform_keypoints}") print(f"Transforming bbox = {transform_bbox}") print(f"Transforming segmentation = {transform_segmentation}")