Can't use ImageFolder

Can’t use ImageFolder.

Hi! I want to load my image dataset, and I want to use ImageFolder to do that. this is my code:

from datasets import load_dataset

dataset = load_dataset(“imagefolder”, data_dir= “./folder”)

and this is the error:

ValueError : At least one data file must be specified, but got data_files=None

and this is my folder structure:
folder/train/label_0/x1.png
folder/train/label_0/xn.png
folder/train/label_1/x1.png
folder/train/label_1/xn.png
.
.
.
folder/train/label_9/x1.png
folder/train/label_9/xn.png
I would appreciate it if anyone could help me with that and give me some tips to use ImageFolder in a proper manner.

cc @mariosasko

1 Like

Hi! Sadly I can’t reproduce the error locally. Can you please update the datasets installation to the newest version with pip install -U datasets and try again?

Also, what the following code outputs in your env when you run it?

import os
from fsspec.implementations.local import LocalFileSystem
print(LocalFileSystem().glob(os.path.join("./folder", "**train*")))
2 Likes

Hi @mariosasko!
updating datasets to its newest version solved my problem!
Thank you so much :star_struck: :heart_eyes: :pray: