# Undesired behavior when using load\_dataset

**URL:** <https://discuss.huggingface.co/t/undesired-behavior-when-using-load-dataset/35123>\
**Category:** 🤗Datasets\
**Created:** [March 30, 2023, 5:31pm UTC](https://discuss.huggingface.co/t/undesired-behavior-when-using-load-dataset/35123 "2023-03-30T17:31:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![baldesco](https://avatars.discourse-cdn.com/v4/letter/b/bc79bd/32.png) [@baldesco](https://discuss.huggingface.co/u/baldesco)\
**Post date:** [March 30, 2023, 5:31pm UTC](https://discuss.huggingface.co/t/undesired-behavior-when-using-load-dataset/35123/1 "2023-03-30T17:31:43Z")

</div>

Hello,

I have a folder with 6.000 images, and a **metadata.csv** file that contains two columns: `file_name` and `label`.

I am trying to create a dataset using this command:

```auto
from datasets import load_dataset

dataset = load_dataset("imagefolder", data_dir="data/food_imgs", split='train')

```

But, as a result, I only get one row:

```auto
Dataset({
    features: ['image', 'label'],
    num_rows: 1
})

```

How can I fix this? I should have 6.000 rows in the dataset.

---

<div class="post-metadata">

**Author:** ![akuysal](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/akuysal/32/23405_2.png) [@akuysal](https://discuss.huggingface.co/u/akuysal)\
**Post date:** [March 30, 2023, 11:06pm UTC](https://discuss.huggingface.co/t/undesired-behavior-when-using-load-dataset/35123/2 "2023-03-30T23:06:18Z")

</div>

I tried to execute your code with an image folder in my computer. In the folder, I have two subfolders namely ants and bees. There are 245 images in two categories. After running your script, I get the output below. It seems it is working as expected.

Dataset({  
features: [‘image’, ‘label’],  
num\_rows: 245  
})

When I include two more lines to the code as below, I can get the following output showing that there are two labels attached to the images.

print(dataset[0])  
print(dataset[150])

{‘image’: \<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=768x512 at 0x1F0AC70A3D0\>, ‘label’: 0}  
{‘image’: \<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=500x375 at 0x1F0AC70A1C0\>, ‘label’: 1}

---

<div class="post-metadata">

**Author:** ![baldesco](https://avatars.discourse-cdn.com/v4/letter/b/bc79bd/32.png) [@baldesco](https://discuss.huggingface.co/u/baldesco)\
**Post date:** [March 30, 2023, 11:32pm UTC](https://discuss.huggingface.co/t/undesired-behavior-when-using-load-dataset/35123/3 "2023-03-30T23:32:19Z")

</div>

What version of `datasets` do you have?

---

<div class="post-metadata">

**Author:** ![akuysal](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/akuysal/32/23405_2.png) [@akuysal](https://discuss.huggingface.co/u/akuysal)\
**Post date:** [April 1, 2023, 8:39pm UTC](https://discuss.huggingface.co/t/undesired-behavior-when-using-load-dataset/35123/4 "2023-04-01T20:39:13Z")

</div>

It seems the version of datasets is 2.9.0. I installed it using PyCharm package manager.

---

<div class="post-metadata">

**Author:** ![baldesco](https://avatars.discourse-cdn.com/v4/letter/b/bc79bd/32.png) [@baldesco](https://discuss.huggingface.co/u/baldesco)\
**Post date:** [April 17, 2023, 1:25pm UTC](https://discuss.huggingface.co/t/undesired-behavior-when-using-load-dataset/35123/5 "2023-04-17T13:25:13Z")

</div>

I finally found the issue. One of the images contained the word “training” in its file name, and it seems that, in this case, the `load_dataset` function assumes that I only want to upload images with “training” in the name, as if it was the split.

That is why I was only getting one image as a return. This should be better documented
