# Create Dataset from Images and Annotations locally

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcreate-dataset-from-images-and-annotations-locally%2F91526%3E%5C
**Category:** 🤗Transformers\
**Created:** [June 11, 2024, 12:01pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcreate-dataset-from-images-and-annotations-locally%2F91526 "2024-06-11T12:01:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![berniberni](https://avatars.discourse-cdn.com/v4/letter/b/73ab20/32.png) [@berniberni](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fberniberni)%5C
**Post date:** [June 11, 2024, 12:01pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcreate-dataset-from-images-and-annotations-locally%2F91526%2F1 "2024-06-11T12:01:03Z")

</div>

I am trying to create a Dataset to finetune a segmentation model. My images are stored in a folder and so are the annotation images which I’ve generated by segmenting images (I will accept these as my ground truth for this instance). The annotations are in folders organized by the label name. (root/road/imgs; root/sky/imgs; etc.)  
In the docs or when downloading segmentation datasets the “annotation” is always a type of grey value image; do I have to combine my annotation images into grey scale images (“segmentation maps”)? How do I do this? Or can I simply load the annotation images into the dataset all separately? There are these “Folder-based Builders” in the docs for loading image datasets but if I load my annotations it doesn’t contain the RGB images? If you know what I’m talking about please help! Thanks in advance

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [June 11, 2024, 8:38pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcreate-dataset-from-images-and-annotations-locally%2F91526%2F2 "2024-06-11T20:38:20Z")

</div>

Hi,

We have a guide for that in the examples:

- instance segmentation: [transformers/examples/pytorch/instance-segmentation at main · huggingface/transformers · GitHub](https://github.com/huggingface/transformers/tree/main/examples/pytorch/instance-segmentation#note-on-custom-data)
- semantic segmentation: [transformers/examples/pytorch/semantic-segmentation at main · huggingface/transformers · GitHub](https://github.com/huggingface/transformers/tree/main/examples/pytorch/semantic-segmentation#note-on-custom-data)

---

<div class="post-metadata">

**Author:** ![berniberni](https://avatars.discourse-cdn.com/v4/letter/b/73ab20/32.png) [@berniberni](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fberniberni)%5C
**Post date:** [June 12, 2024, 11:45am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcreate-dataset-from-images-and-annotations-locally%2F91526%2F3 "2024-06-12T11:45:11Z")

</div>

I’ve seen this entry and it’s not what the question is about but thanks!

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [June 12, 2024, 2:15pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fcreate-dataset-from-images-and-annotations-locally%2F91526%2F4 "2024-06-12T14:15:29Z")

</div>

Hi,

Sorry misread your question, no they can also be RGB, you can cast them to be of type [datasets.feature.Image](https://huggingface.co/docs/datasets/en/about_dataset_features#image-feature). Basically you’d need to create a dataset with 2 columns (“image” and “annotation” and both can be of type Image).
