# ImageFolder dataloading guidance

**URL:** <https://discuss.huggingface.co/t/imagefolder-dataloading-guidance/27862>\
**Category:** Beginners\
**Created:** [December 15, 2022, 11:46am UTC](https://discuss.huggingface.co/t/imagefolder-dataloading-guidance/27862 "2022-12-15T11:46:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kanlions](https://avatars.discourse-cdn.com/v4/letter/k/5daacb/32.png) [@kanlions](https://discuss.huggingface.co/u/kanlions)\
**Post date:** [December 15, 2022, 11:46am UTC](https://discuss.huggingface.co/t/imagefolder-dataloading-guidance/27862/1 "2022-12-15T11:46:20Z")

</div>

Hi I have all images in óne folder and a txt file in which class information is there. Apologies for asking a basic question but I am not able to extract labels from the data loader even I tried converting it into a json file. Please can anyone share a tutorial if they have worked with image data in which all the images are in a single folder.

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](https://discuss.huggingface.co/u/nielsr)\
**Post date:** [December 15, 2022, 12:03pm UTC](https://discuss.huggingface.co/t/imagefolder-dataloading-guidance/27862/2 "2022-12-15T12:03:13Z")

</div>

You can write some Python code to put the images in folders based on their classes, as this is the format that ImageFolder requires.

---

<div class="post-metadata">

**Author:** ![ravitejac](https://avatars.discourse-cdn.com/v4/letter/r/71e660/32.png) [@ravitejac](https://discuss.huggingface.co/u/ravitejac)\
**Post date:** [December 16, 2022, 2:35am UTC](https://discuss.huggingface.co/t/imagefolder-dataloading-guidance/27862/3 "2022-12-16T02:35:02Z")

</div>

You can create a metadata.jsonl file containing labels(class information) and image paths and then add the metadata file to the folder containing all images. Documentation is [here](https://huggingface.co/docs/datasets/image_dataset#imagefolder:~:text=If%20there%20is%20additional%20information%20you%E2%80%99d%20like%20to%20include%20about%20your%20dataset%2C%20like%20text%20captions%20or%20bounding%20boxes%2C%20add%20it%20as%20a%20metadata.jsonl%20file%20in%20your%20folder.%20This%20lets%20you%20quickly%20create%20datasets%20for%20different%20computer%20vision%20tasks%20like%20text%20captioning%20or%20object%20detection.). Sharing the txt file format can help you get a more clear answer.
