TypeError: expected str, bytes or os.PathLike object, not dict
State: open

### Describe the bug

my dataset is in form : train- image /n -labels

and tried the code:
```
from datasets import load_dataset

data_files = {
    "train": "/content/datasets/PotholeDetectionYOLOv8-1/train/",
      "validation": "/content/datasets/PotholeDetectionYOLOv8-1/valid/",
      "test": "/content/datasets/PotholeDetectionYOLOv8-1/test/"
}
dataset = load_dataset("imagefolder", data_dir=data_files)
dataset
```
got error:
```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[<ipython-input-29-2ef1926f73d9>](https://localhost:8080/#) in <cell line: 8>()
      6       "test": "/content/datasets/PotholeDetectionYOLOv8-1/test/"
      7 }
----> 8 dataset = load_dataset("imagefolder", data_dir=data_files)
      9 dataset

6 frames
[/usr/lib/python3.10/pathlib.py](https://localhost:8080/#) in _parse_args(cls, args)
    576                 parts += a._parts
    577             else:
--> 578                 a = os.fspath(a)
    579                 if isinstance(a, str):
    580                     # Force-cast str subclasses to str (issue #21127)

TypeError: expected str, bytes or os.PathLike object, not dict
```

### Steps to reproduce the bug

as share above 

### Expected behavior

load images and labels , but my dataset only uploads images 
- https://huggingface.co/datasets/Andyrasika/potholes-dataset

### Environment info

colab pro 

You should be able to load the images by modifying the `load_dataset` call like this:
```python
dataset = load_dataset("imagefolder", data_dir="/content/datasets/PotholeDetectionYOLOv8-1")
```

The `imagefolder` builder expects the image files to be in `path/label/image_file` (e.g. .`.../train/dog/image_1.jpg`), so the solution for the labels in your case is to create metadata files (one for each split; as explained [here](https://huggingface.co/docs/datasets/image_dataset#imagefolder)) that map the images to their labels.

> You should be able to load the images by modifying the `load_dataset` call like this:
> 
> ```python
> dataset = load_dataset("imagefolder", data_dir="/content/datasets/PotholeDetectionYOLOv8-1")
> ```
> 
> The `imagefolder` builder expects the image files to be in `path/label/image_file` (e.g. .`.../train/dog/image_1.jpg`), so the solution for the labels in your case is to create metadata files (one for each split; as explained [here](https://huggingface.co/docs/datasets/image_dataset#imagefolder)) that map the images to their labels.

I tried like this but only uploads images and not labels, Andyrasika/potholes-dataset

As explained in my previous comment, you need to define metadata files to load the labels or update the paths to be in the format `train/label/image` (`train- image /n -labels` is not supported by the loader).

I downloaded my file after annotating using roboflow . It gives train-
images, labels ,  test- images, labels , valid- images, labels . I hope it
gives you an idea of the dataset . Please advise on this dataset

On Tue, Oct 10, 2023 at 18:12 Mario Šaško ***@***.***> wrote:

> As explained in my previous comment, you need to define metadata files to
> load the labels or update the paths to be in the format train/label/image
> (train- image /n -labels is not supported by the loader).
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/datasets/issues/6285#issuecomment-1755335215>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AE4LJNN56FWWTSBYTSTUWHLX6U7CVAVCNFSM6AAAAAA5YHCSTGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJVGMZTKMRRGU>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>