# ImageFolder mode of the Image

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimagefolder-mode-of-the-image%2F84063%3E%5C
**Category:** 🤗Datasets\
**Created:** [April 27, 2024, 4:54pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimagefolder-mode-of-the-image%2F84063 "2024-04-27T16:54:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tankwell](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/tankwell/32/18511_2.png) [@tankwell](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ftankwell)%5C
**Post date:** [April 27, 2024, 4:54pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimagefolder-mode-of-the-image%2F84063%2F1 "2024-04-27T16:54:29Z")

</div>

Hello

I have seen there is an option to load image with ‘mode’ = ‘RGB’, but I could not see a proper way to pass this argument while creating the Image feature for the dataset.

```auto
dataset = load_dataset(
            'imagefolder',
            data_dir=cfg.data.dataset_name_or_path,
            mode='rgb'
)
## causes error....

```

How can I deal with mixed folder containing RGB / RGBA? I would like all the folders would have the same format

Thanks!

---

<div class="post-metadata">

**Author:** ![lhoestq](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lhoestq/32/64813_2.png) [@lhoestq](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Flhoestq)%5C
**Post date:** [May 27, 2024, 12:42pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimagefolder-mode-of-the-image%2F84063%2F2 "2024-05-27T12:42:19Z")

</div>

You need to define `Image(mode="RGB")` and use it to define/cast your `features`

---

<div class="post-metadata">

**Author:** ![tankwell](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/tankwell/32/18511_2.png) [@tankwell](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ftankwell)%5C
**Post date:** [May 27, 2024, 1:54pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimagefolder-mode-of-the-image%2F84063%2F3 "2024-05-27T13:54:58Z")

</div>

eventually I was doing this using map on the image feature in order to convert them all to RGB

But I was thinking on something that I can add up to the builtin dataset creation module, since the imagefolder framework also reads the Image column as PIL image

Thank you!

---

<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:** [May 28, 2024, 1:55am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimagefolder-mode-of-the-image%2F84063%2F4 "2024-05-28T01:55:31Z")

</div>

Closed on May 28, 2024, 1:55am UTC

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

---

<div class="post-metadata">

**Author:** ![lhoestq](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lhoestq/32/64813_2.png) [@lhoestq](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Flhoestq)%5C
**Post date:** [June 4, 2024, 11:31am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fimagefolder-mode-of-the-image%2F84063%2F5 "2024-06-04T11:31:21Z")

</div>

You can try to override the features and use `Image(mode="RGB")` by passing them as `features=` to `load_dataset`
