# ImageFolder dataset builder for HF Hub dataset

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimagefolder-dataset-builder-for-hf-hub-dataset%2F74383%3E%5C
**Category:** 🤗Datasets\
**Created:** [February 22, 2024, 5:12pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimagefolder-dataset-builder-for-hf-hub-dataset%2F74383 "2024-02-22T17:12:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![justin-witter](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@justin-witter](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjustin-witter)%5C
**Post date:** [February 22, 2024, 5:12pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimagefolder-dataset-builder-for-hf-hub-dataset%2F74383%2F1 "2024-02-22T17:12:16Z")

</div>

I’ve been using `load_dataset("imagefolder", data_dir="...")` to load a local dataset of images and assign a series of labels from an included `metadata.csv` file for multi-label image classification.

However, I uploaded that dataset to the Hub and now load it in using `load_dataset("hf_name",data_dir="...")` but since I have to specify the Hub directory name instead of “imagefolder” for the path parameter, the labels in `metadata.csv` aren’t being assigned anymore.

Is there a way to fix this?

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [February 22, 2024, 9:20pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimagefolder-dataset-builder-for-hf-hub-dataset%2F74383%2F2 "2024-02-22T21:20:38Z")

</div>

Hi,

If loading from the hub, you don’t need to specify `data_dir` anymore.

---

<div class="post-metadata">

**Author:** ![justin-witter](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@justin-witter](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjustin-witter)%5C
**Post date:** [February 22, 2024, 9:26pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimagefolder-dataset-builder-for-hf-hub-dataset%2F74383%2F3 "2024-02-22T21:26:17Z")

</div>

Ah thanks for the suggestion. Still having trouble with labels being assigned using the metadata.csv though.

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [February 24, 2024, 11:02am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimagefolder-dataset-builder-for-hf-hub-dataset%2F74383%2F4 "2024-02-24T11:02:58Z")

</div>

This is explained in detail here: [Create an image dataset](https://huggingface.co/docs/datasets/en/image_dataset#imagefolder).

---

<div class="post-metadata">

**Author:** ![justin-witter](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@justin-witter](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fjustin-witter)%5C
**Post date:** [February 26, 2024, 6:19pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimagefolder-dataset-builder-for-hf-hub-dataset%2F74383%2F5 "2024-02-26T18:19:22Z")

</div>

The issue was that I had an extra image in the Hub directory that wasn’t included in the metadata.csv file. Removed the image and labels are being assigned now!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsystem)%5C
**Post date:** [February 27, 2024, 6:19am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimagefolder-dataset-builder-for-hf-hub-dataset%2F74383%2F6 "2024-02-27T06:19:42Z")

</div>

Closed on February 27, 2024, 6:19am UTC

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
