How do I create a Image Segmentation Dataset

You have to have a DatasetDict Format with image/pixel_values and label, alternatively you can also create like this,

data
 |-training
 |     |-image
 |          |-img_id.jpg
 |    |-mask
 |          |-mask_id.jpg
└──validation
     |-image
          |-img_id.jpg
     |-mask
          |-mask_id.jpg

Using this you can create a dataset class and read and create a dataset dict, this format worked for me along with the model.

Yes, the guide is here: https://github.com/huggingface/transformers/tree/main/examples/pytorch/semantic-segmentation#note-on-custom-data

1 Like

sweet exactly what I was looking for :star_struck::+1:t2:
Thank you @NimaBoscarino

This guide is in the docs now :slight_smile: Image Segmentation

Hi
Could you please let me know how should I prepare my dataset while I have more than 256 classes?

Hi @coder31, you should probably do it the same way as in the guide provided by @nielsr. Please let me know if you face any errors/difficulties. I would also recommend paying attention to ignore_index in the loss function because it is 255 by default and it will ignore the class with id=255 if you do not modify it.