# From where can I import the get\_coco\_api\_from\_dataset module?

**URL:** <https://discuss.huggingface.co/t/from-where-can-i-import-the-get-coco-api-from-dataset-module/18894>\
**Category:** 🤗Datasets\
**Created:** [June 9, 2022, 6:50am UTC](https://discuss.huggingface.co/t/from-where-can-i-import-the-get-coco-api-from-dataset-module/18894 "2022-06-09T06:50:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dawny33](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/dawny33/32/5020_2.png) [@Dawny33](https://discuss.huggingface.co/u/Dawny33)\
**Post date:** [June 9, 2022, 6:50am UTC](https://discuss.huggingface.co/t/from-where-can-i-import-the-get-coco-api-from-dataset-module/18894/1 "2022-06-09T06:50:17Z")

</div>

I have been following this tutorial: [Transformers-Tutorials/Fine\_tuning\_DetrForObjectDetection\_on\_custom\_dataset\_(balloon).ipynb at master · NielsRogge/Transformers-Tutorials · GitHub](https://github.com/NielsRogge/Transformers-Tutorials/blob/master/DETR/Fine_tuning_DetrForObjectDetection_on_custom_dataset_(balloon).ipynb)

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?

---

<div class="post-metadata">

**Author:** ![mariosasko](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mariosasko/32/31548_2.png) [@mariosasko](https://discuss.huggingface.co/u/mariosasko)\
**Post date:** [June 9, 2022, 11:35am UTC](https://discuss.huggingface.co/t/from-where-can-i-import-the-get-coco-api-from-dataset-module/18894/2 "2022-06-09T11:35:59Z")

</div>

Hi! The linked notebook uses COCO from [this repository](https://github.com/facebookresearch/detr.git) (notice the `datasets` package in it), and not the one from 🤗 `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.

---

<div class="post-metadata">

**Author:** ![davanstrien](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/davanstrien/32/31959_2.png) [@davanstrien](https://discuss.huggingface.co/u/davanstrien)\
**Post date:** [July 15, 2022, 1:48pm UTC](https://discuss.huggingface.co/t/from-where-can-i-import-the-get-coco-api-from-dataset-module/18894/3 "2022-07-15T13:48:07Z")

</div>

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)](https://github.com/bigscience-workshop/lam) and I’m keen to make them as consistent with other approaches as possible 🙂

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!

---

<div class="post-metadata">

**Author:** ![mariosasko](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mariosasko/32/31548_2.png) [@mariosasko](https://discuss.huggingface.co/u/mariosasko)\
**Post date:** [July 21, 2022, 2:13pm UTC](https://discuss.huggingface.co/t/from-where-can-i-import-the-get-coco-api-from-dataset-module/18894/4 "2022-07-21T14:13:22Z")

</div>

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](https://github.com/huggingface/datasets/issues/4618) for discussion)

---

<div class="post-metadata">

**Author:** ![davanstrien](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/davanstrien/32/31959_2.png) [@davanstrien](https://discuss.huggingface.co/u/davanstrien)\
**Post date:** [July 22, 2022, 10:53am UTC](https://discuss.huggingface.co/t/from-where-can-i-import-the-get-coco-api-from-dataset-module/18894/5 "2022-07-22T10:53:52Z")

</div>

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](https://github.com/huggingface/datasets/pull/3468) as a starting point for a coco style dataset?

---

<div class="post-metadata">

**Author:** ![mariosasko](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mariosasko/32/31548_2.png) [@mariosasko](https://discuss.huggingface.co/u/mariosasko)\
**Post date:** [August 8, 2022, 12:44pm UTC](https://discuss.huggingface.co/t/from-where-can-i-import-the-get-coco-api-from-dataset-module/18894/6 "2022-08-08T12:44:29Z")

</div>

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