# HF Dataset to COCO format dataset

**URL:** <https://discuss.huggingface.co/t/hf-dataset-to-coco-format-dataset/46710>\
**Category:** 🤗Datasets\
**Created:** [July 13, 2023, 3:46pm UTC](https://discuss.huggingface.co/t/hf-dataset-to-coco-format-dataset/46710 "2023-07-13T15:46:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![thiagohersan](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/thiagohersan/32/17442_2.png) [@thiagohersan](https://discuss.huggingface.co/u/thiagohersan)\
**Post date:** [July 13, 2023, 3:46pm UTC](https://discuss.huggingface.co/t/hf-dataset-to-coco-format-dataset/46710/1 "2023-07-13T15:46:53Z")

</div>

Hello.

Before I roll my own, figured I’d ask… maybe I just didn’t find it…

Let’s say I have an Object Detection kind of dataset in HF hub that follows the DatasetDict format like the [fashionpedia](https://huggingface.co/datasets/detection-datasets/fashionpedia) dataset.

Are there dataset functions that will convert entries from these to the [COCO-format](https://cocodataset.org/#format-data) ?

I saw the discussion (topic: 34894) about YOLO → DETR/COCO, but would be nice to keep the data in HF format and then transform the entries to YOLO or COCO or “other” as needed.

Thanks.

---

<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 14, 2023, 11:53am UTC](https://discuss.huggingface.co/t/hf-dataset-to-coco-format-dataset/46710/2 "2023-07-14T11:53:41Z")

</div>

No, we don’t have a function for converting to the COCO format in the API

---

<div class="post-metadata">

**Author:** ![thiagohersan](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/thiagohersan/32/17442_2.png) [@thiagohersan](https://discuss.huggingface.co/u/thiagohersan)\
**Post date:** [July 14, 2023, 1:49pm UTC](https://discuss.huggingface.co/t/hf-dataset-to-coco-format-dataset/46710/3 "2023-07-14T13:49:08Z")

</div>

👍 Thanks @mariosasko

---

<div class="post-metadata">

**Author:** ![roy650](https://avatars.discourse-cdn.com/v4/letter/r/ecc23a/32.png) [@roy650](https://discuss.huggingface.co/u/roy650)\
**Post date:** [December 28, 2023, 4:29pm UTC](https://discuss.huggingface.co/t/hf-dataset-to-coco-format-dataset/46710/4 "2023-12-28T16:29:04Z")

</div>

Did you do it and can share?

---

<div class="post-metadata">

**Author:** ![thiagohersan](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/thiagohersan/32/17442_2.png) [@thiagohersan](https://discuss.huggingface.co/u/thiagohersan)\
**Post date:** [December 29, 2023, 1:09am UTC](https://discuss.huggingface.co/t/hf-dataset-to-coco-format-dataset/46710/5 "2023-12-29T01:09:47Z")

</div>

Hi @roy650 .

Take a look at the `CocordiaisDataset` class in this [file](https://github.com/the-happy-team/detr-painting-faces/blob/main/Cocordiais.py#L111).

And how to use it is [in here](https://github.com/the-happy-team/detr-painting-faces/blob/main/finetune-detr-ptl.ipynb) somewhere in the first couple of cells.

I haven’t used these in a while, so I don’t remember if there was anything un-intuitive.

~~I can give you access to the dataset too if that would help.~~

I gave you access to the dataset [here](https://huggingface.co/datasets/thiagohersan/cordiais-faces).

---

<div class="post-metadata">

**Author:** ![roy650](https://avatars.discourse-cdn.com/v4/letter/r/ecc23a/32.png) [@roy650](https://discuss.huggingface.co/u/roy650)\
**Post date:** [December 31, 2023, 7:24am UTC](https://discuss.huggingface.co/t/hf-dataset-to-coco-format-dataset/46710/6 "2023-12-31T07:24:03Z")

</div>

Thanks @thiagohersan . I appreciate it.  
The code looks pretty much like what I need barring minimal changes for my HF structure.  
The dataset is still inaccessible despite the fact I got an email with access granted, but don’t worry about it - I don’t need it.  
Thanks again!
