# Load\_dataset with labels

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fload-dataset-with-labels%2F82066%3E%5C
**Category:** 🤗Datasets\
**Created:** [April 16, 2024, 4:16pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fload-dataset-with-labels%2F82066 "2024-04-16T16:16:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![iltranqui](https://avatars.discourse-cdn.com/v4/letter/i/ecae2f/32.png) [@iltranqui](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Filtranqui)%5C
**Post date:** [April 16, 2024, 4:16pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fload-dataset-with-labels%2F82066%2F1 "2024-04-16T16:16:57Z")

</div>

I have a datest for semantic segmentation with the following structure:

```auto
Dataset
├── image
│ ├── *.jpg
├── annotation
│ ├── *.png

```

And using the load\_dataset with the imagefolder as here:

```auto
dataset = load_dataset("imagefolder", data_dir=os.path.join(path,'repositories/data/dataset/'), split='train')
dataset[0]

```

it does the following:

```auto
{'image': <PIL.PngImagePlugin.PngImageFile image mode=I;16 size=1098x566>,
 'label': 0} # it can't detect the PNG files but the jpg files it does

```

I tried changing the names of the folders to label, labels, and annotation but it didn’t work. On how to do the splits it is clear in the documentation, but this division with labels I didn’t understand.  
I solved the problem by doing it this way, looking for it in these forums:

```auto
import datasets
import glob

IMAGES = glob.glob(os.path.join(path,'repositories/data/dataset/image/*.jpg'))
SEG_MAPS = glob.glob(os.path.join(path,'repositories/data/dataset/annotation/*.png'))

dataset = datasets.Dataset.from_dict({"image": IMAGES, "annotation": SEG_MAPS},
                                     features=datasets.Features(
                                         {"image": datasets.Image(),
                                          "annotation": datasets.Image()})
                                     )

```

My question is: where did I made a mistake or I missed a documentation ? I would like to just give just the image folder and the data\_dir
