Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't import a COCO Dataset #1630

Open
nasserdr opened this issue Oct 4, 2024 · 1 comment
Open

Can't import a COCO Dataset #1630

nasserdr opened this issue Oct 4, 2024 · 1 comment
Assignees

Comments

@nasserdr
Copy link

nasserdr commented Oct 4, 2024

I have one image and one annotation file that I am trying to import using datumaro but I am getting an error:

could't match this file with any of these tasks: coco_instances,coco_person_keypoints ...

My code is:
`from datumaro import Dataset

dataset = Dataset.import_from("/home/dataset", format="coco")

dataset
`

The dataset folder is structured as follows:
home
----dataset
--------Images
------------DJI_20210901143844_0969_02_02.png
--------Annotations
------------DJI_20210901143844_0969_02_02.json

I am getting this error:

`---------------------------------------------------------------------------
DatasetNotFoundError Traceback (most recent call last)
Cell In[10], line 13
8 ids += [item.id]
10 return ids
---> 13 dataset = Dataset.import_from("/home/naro/data/RumexV0/Test2", format="coco")
14 subset = "default"
15 ids = get_ids(dataset, subset)

File ~/.conda/envs/images/lib/python3.10/site-packages/datumaro/components/dataset.py:832, in Dataset.import_from(cls, path, format, env, progress_reporter, error_policy, **kwargs)
829 importer = env.make_importer(format)
830 with logging_disabled(log.INFO):
831 detected_sources = (
--> 832 importer(path, stream=cls._stream, **kwargs)
833 if importer.can_stream
834 else importer(path, **kwargs)
835 )
836 extractor_merger = importer.get_extractor_merger()
837 elif format in env.extractors:

File ~/.conda/envs/images/lib/python3.10/site-packages/datumaro/plugins/data_formats/coco/importer.py:78, in CocoImporter.call(self, path, stream, **extra_params)
75 subsets = self.find_sources(path)
77 if len(subsets) == 0:
---> 78 raise DatasetNotFoundError(path, self.NAME)
80 # TODO: should be removed when proper label merging is implemented
...
(...)
86 CocoTask.stuff,
87 }

DatasetNotFoundError: Failed to find dataset 'coco' at '/home/dataset'
`

Attached the json file and the image:
DJI_20210901143828_0957_02_02.json
(I can't upload the image because it's more than 10 MB)

@sooahleex
Copy link
Contributor

Hi @nasserdr sorry for the late reply, thanks for your interest in our project.
I checked the structure of your dataset, and your dataset has a little bit different structure with which we support. This is the structure we support for coco

└─ Dataset/
    ├── dataset_meta.json # a list of custom labels (optional)
    ├── images/
    │   ├── train/
    │   │   ├── <image_name1.ext>
    │   │   ├── <image_name2.ext>
    │   │   └── ...
    │   └── val/
    │       ├── <image_name1.ext>
    │       ├── <image_name2.ext>
    │       └── ...
    └── annotations/
        ├── <task>_<subset_name>.json
        └── ...

For more information, please refer to this document.
So your dataset does not have a subset for each image. Please check the structure of the dataset and if there is a problem even though it is the same as the structure we support, please give me an example of the dataset and let me know and I will check it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants