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’t 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.

3 Likes

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

I’m planning to add some as part of GitHub - bigscience-workshop/lam: Libraries, Archives and Museums (LAM) and I’m 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’t a canonical/suggested approach I’ll borrow some code from one of these!

Hi @davanstrien. We don’t 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’m 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