From where can I import the get_coco_api_from_dataset module?

I have been following this tutorial: Transformers-Tutorials/Fine_tuning_DetrForObjectDetection_on_custom_dataset_(balloon).ipynb at master 路 NielsRogge/Transformers-Tutorials 路 GitHub

While trying to evaluate the model, I should be using from datasets import get_coco_api_from_dataset. However, I am getting an ImportError while doing that:

ImportError: cannot import name 'get_coco_api_from_dataset'

I don鈥檛 seem to find the coco_eval module too. So, this line fails: from datasets.coco_eval import CocoEvaluator. Were the coco-related modules shifted somewhere, or do I need to import them from a different package?

Can someone please help me understand how do I import this module?

Hi! The linked notebook uses COCO from this repository (notice the datasets package in it), and not the one from :hugs: datasets (we are in the process of adding it to the lib). As long as you execute all the commands from the notebook up to that import, the import should work, and locally you can clone the repo and add it to sys.path (import sys; sys.path.insert(0, "path/to/repo")) to make it visible to the import system.


Just wanted to check if there was any suggestions for the current best way to load COCO style data into the datasets library?

I鈥檓 planning to add some as part of GitHub - bigscience-workshop/lam: Libraries, Archives and Museums (LAM) and I鈥檓 keen to make them as consistent with other approaches as possible :slight_smile:

I know there are some other COCO style datasets on the hub so if there isn鈥檛 a canonical/suggested approach I鈥檒l borrow some code from one of these!

Hi @davanstrien. We don鈥檛 host a canonical implementation of the COCO loader at the moment, but I think it would be great to have it as a community loader (see contribute data loading for object detection datasets with yolo data format 路 Issue #4618 路 huggingface/datasets 路 GitHub for discussion)

That sounds like a nice approach. I will start with a few specific loaders for the datasets I鈥檓 going to be working on and then see about abstracting that out into a more general loader.

Do you see any issues with using your previous PR Add COCO dataset by mariosasko 路 Pull Request #3468 路 huggingface/datasets 路 GitHub as a starting point for a coco style dataset?

I see no issues with that :slight_smile:, so feel free to borrow the code from there.

1 Like