from_coco#
- from_coco(coco_json: Path | str, images_root: Path | str | None = None, dataset_name: str | None = None, split: str | None = None, label_map: dict[int, str] | None = None, box_format: str = 'XYWH', drop_columns: Iterable[str] = ('iscrowd', 'segmentation')) Dataset[source]#
Load a coco json file into a dictionary. Note that there is only one split per file, which needs to be given by caller. See specifications (only Object detection)
Notes
from_cocois compatible with bounding box annotations withoutcategory_idfield, but then you will need to have a label map of only one entry, which will be assigned to every bounding box.If split value is not given, it will try to deduce it from the file name. More specifically, it will search a
<name>_<split>.jsonpattern and assignnameto the dataset name andsplitto the split value.
- Parameters:
coco_json – path of json file
images_root – folder which file_name of images are relative to
dataset_name – If specified, will be the dataset name, used when showing the dataset or exporting in other formats such as fiftyone. If not specified, the dataset name will be deduced from the name of the json file.
split – split of given json file. If not set, will try to deduce from filename. Defaults to None.
label_map – Optional dictionary to specify the name of each category id. If not set, will try to deduce it from the json itself, in the field categories at its root.
box_format – what type of annotation the json file will have. It will be converted back to XYWH. Defaults to XYWH
drop_columns – list of names of columns that need to be dropped from the parsed json dictionary.
- Returns:
Loaded dataset object