Automatically add filename for image/audio folder
Opened by patrickvonplaten (open)

### Feature request

When creating a custom audio of image dataset, it would be great to automatically have access to the filename. It should be both:
a) Automatically displayed in the viewer
b) Automatically added as a column to the dataset when doing `load_dataset`

In `diffusers` our test rely quite heavily on images and audio files now and it's a bit tedious at the moment to download specific images from a datasets repo. 

E.g. we have a dataset of images for tests in `diffusers`: https://huggingface.co/datasets/hf-internal-testing/diffusers-images
where it would be extremely nice to have direct access to the filename both visually on the datasets page (@severo ) as well as via the `load_datasets` function. We currently have some akward functionality to download images by path name: https://github.com/huggingface/diffusers/blob/2fb8fafa4b761f6fc144cf75a6f6f0ea6af3a1c1/src/diffusers/utils/testing_utils.py#L131 
It would be much nicer to just go over `load_dataset(...)` 

### Motivation

Intuitively the filename is something people understand directly. E.g if you upload a folder of images online, it's nice if you recognize the image as well as the filename next to it directly and that you're able to use it right away. 

The label on the other hand is less intuitive to understand as you haven't added it yourself.

### Your contribution

Not sure if I have the time to add it myself anytime soon, but it would help us a lot for `diffusers`.

Comments:
Also cc @anton-l 

BTW the exact same holds true for the audio folder

I'm fine with adding a new column with the file name personally. Not sure how breaking this is though

@patrickvonplaten do you mean just filename or full relative path inside the repo?
I think it shouldn't be breaking, at least I cannot come up with any case where it is. Maybe @mariosasko can?

also I think that the problem here and in general is that Image/AudioFolder has default configuration which implies automatic label creation if there is not metadata file. It can be changed when you load the dataset with `load_dataset` but not on it's Hub page. 



> also I think that the problem here and in general Image/AudioFolder has default configuration which implies automatic label creation if there is not metadata file

Yea I agree it's often the wrong default. We can also imagine adding the builder's parameters as YAML in the repo.

@lhoestq yes I also got the idea of some YAML config! not sure of what priority it is though.

but it would actually also solve this issue: https://github.com/huggingface/datasets/issues/5153

I meant just the file name (no path) that would already be super helpful IMO :-) (maybe dir+filename if there are dirs in the folder)

@patrickvonplaten one more time, to be sure I understand you.
For example, we have data structure like this:
```
├─ data/
│  └─ subdir/
│     └── cats/
│          ├── 0.jpg
│          ├── 1.jpg
│          └── 2.jpg
│     └── dogs/
│          ├── 0.jpg
│          ├── 1.jpg
│          └── 2.jpg
└── another_subdir/
      ├── 10.jpg
      ├── 11.jpg
      └── 12.jpg
```
Is it okay to provide `"data/subdir/cats/0.jpg"`, `"data/subdir/dogs/0.jpg"`, `"data/another_subdir/10.jpg"`?
I think providing just filenames might be confusing if they are not unique, as in this example. 

Yes I think the relative path as you proposed makes a lot of sense :-)