ImageFolder dataset builder does not read the validation data set if it is named as "val"
CONTRIBUTOR
#take
2022-08-13T06:43:07Z
https://github.com/huggingface/datasets/issues/4839#issuecomment-1213844342
https://api.github.com/repos/huggingface/datasets/issues/4839
IC_kwDODunzps5IWct2
https://api.github.com/repos/huggingface/datasets/issues/comments/1213844342/reactions
2022-08-13T06:43:07Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1213844342
https://avatars.githubusercontent.com/u/98386959?v=4
https://api.github.com/users/akt42/events{/privacy}
https://api.github.com/users/akt42/followers
https://api.github.com/users/akt42/following{/other_user}
https://api.github.com/users/akt42/gists{/gist_id}
https://github.com/akt42
akt42
U_kgDOBd1EDw
https://api.github.com/users/akt42/orgs
https://api.github.com/users/akt42/received_events
https://api.github.com/users/akt42/repos
https://api.github.com/users/akt42/starred{/owner}{/repo}
https://api.github.com/users/akt42/subscriptions
User
https://api.github.com/users/akt42
public
**Is your feature request related to a problem? Please describe.**

Currently, the `'imagefolder'` data set builder in [`load_dataset()`](https://github.com/huggingface/datasets/blob/2.4.0/src/datasets/load.py#L1541] ) only [supports](https://github.com/huggingface/datasets/blob/6c609a322da994de149b2c938f19439bca99408e/src/datasets/data_files.py#L31) the following names as the validation data set directory name: `["validation", "valid", "dev"]`. When the validation directory is named as `'val'`, the Data set will not have a validation split. I expected this to be a trivial task but ended up spending a lot of time before knowing that only the above names are supported.

Here's a minimal example of `val` not being recognized:

```python
import os
import numpy as np
import cv2   
from datasets import load_dataset

# creating a dummy data set with the following structure:

# ROOT
# | -- train
# | ---- class_1
# | ---- class_2
# | -- val
# | ---- class_1
# | ---- class_2


ROOT = "data"


for which in ["train", "val"]:
  for class_name in ["class_1", "class_2"]:
    dir_name = os.path.join(ROOT, which, class_name)
    if not os.path.exists(dir_name):
      os.makedirs(dir_name)
    for i in range(10):
       cv2.imwrite(
           os.path.join(dir_name, f"{i}.png"),
           np.random.random((224, 224))
           )

# trying to create a data set
dataset = load_dataset(
    "imagefolder", 
    data_dir=ROOT
)

>> dataset
DatasetDict({
    train: Dataset({
        features: ['image', 'label'],
        num_rows: 20
    })
})

# ^ note how the dataset only has a 'train' subset

```

**Describe the solution you'd like**

The suggestion is to include `"val"` to  [that list ](https://github.com/huggingface/datasets/blob/6c609a322da994de149b2c938f19439bca99408e/src/datasets/data_files.py#L31) as that's a commonly used phrase to name the validation directory. 

Also, In the documentation, explicitly mention that only such directory names are supported as train/val/test directories to avoid confusion.

**Describe alternatives you've considered**

In the documentation, explicitly mention that only such directory names are supported as train/val/test directories without adding `val` to the above list.


**Additional context**

A question asked in the forum: [
Loading an imagenet-style image dataset with train/val directories](https://discuss.huggingface.co/t/loading-an-imagenet-style-image-dataset-with-train-val-directories/21554)