Skip to content

Commit fd18054

Browse files
committed
Typo fix and more flexible COCO for coco-2017
1 parent 8ed3de1 commit fd18054

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

luxonis_ml/data/parsers/classification_directory_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def validate_split(split_path: Path) -> dict[str, Any] | None:
5353
"valid",
5454
"test",
5555
"val",
56-
"valdation",
56+
"validation",
5757
"images",
5858
"labels",
5959
}

luxonis_ml/data/parsers/coco_parser.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,16 @@ def _is_coco_json(json_path: Path) -> bool:
7777
try:
7878
with open(json_path) as f:
7979
data = json.load(f)
80-
# Distinguish between COCO and FiftyOne classification as they both have labels.json files
81-
return (
82-
isinstance(data, dict)
83-
and "images" in data
84-
and "annotations" in data
85-
and "categories" in data
80+
if not isinstance(data, dict):
81+
return False
82+
# images is required, annotations is optional (test sets don't have them)
83+
if "images" not in data:
84+
return False
85+
# Categories can be at top level or nested inside info
86+
return "categories" in data or (
87+
"info" in data
88+
and isinstance(data["info"], dict)
89+
and "categories" in data["info"]
8690
)
8791
except (json.JSONDecodeError, OSError):
8892
return False

luxonis_ml/data/parsers/luxonis_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class ParserType(Enum):
4040
class LuxonisParser(Generic[T]):
4141
parsers: dict[DatasetType, type[BaseParser]] = {
4242
DatasetType.COCO: COCOParser,
43+
DatasetType.FIFTYONECLS: FiftyOneClassificationParser,
4344
DatasetType.VOC: VOCParser,
4445
DatasetType.DARKNET: DarknetParser,
4546
DatasetType.YOLOV6: YoloV6Parser,
@@ -53,7 +54,6 @@ class LuxonisParser(Generic[T]):
5354
DatasetType.YOLOV8BOUNDINGBOX: YOLOv8Parser,
5455
DatasetType.YOLOV8INSTANCESEGMENTATION: YOLOv8Parser,
5556
DatasetType.YOLOV8KEYPOINTS: YOLOv8Parser,
56-
DatasetType.FIFTYONECLS: FiftyOneClassificationParser,
5757
}
5858

5959
def __init__(

0 commit comments

Comments
 (0)