# Turn of automatic Pil image generation in load\_dataset

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fturn-of-automatic-pil-image-generation-in-load-dataset%2F103222%3E%5C
**Category:** 🤗Datasets\
**Created:** [August 20, 2024, 9:08pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fturn-of-automatic-pil-image-generation-in-load-dataset%2F103222 "2024-08-20T21:08:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![benayat](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@benayat](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fbenayat)%5C
**Post date:** [August 20, 2024, 9:08pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fturn-of-automatic-pil-image-generation-in-load-dataset%2F103222%2F1 "2024-08-20T21:08:18Z")

</div>

when loading a dataset, I have the following arrow format - label: int, image: struct\<bytes:binary, path:string\>. when using load\_dataset() method, the image is automatically converted to Pil image format, and the path is lost. is there a way to avoid that behavior?  
In my example -

```auto
dataset = load_dataset("chronopt-research/cropped-vggface2-224")
for i in range(0, len(dataset['train']), batch_size):
    batch = dataset['train'][i:i + batch_size]
    images = batch['image'] # Original 224x224 images
    labels = batch['label'] # Labels for each image

```

the images I get are only the Pil image object, which doesn’t include the path or file name from the original arrow files.

---

<div class="post-metadata">

**Author:** ![mahmutc](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mahmutc/32/64626_2.png) [@mahmutc](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmahmutc)%5C
**Post date:** [August 21, 2024, 8:37am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fturn-of-automatic-pil-image-generation-in-load-dataset%2F103222%2F2 "2024-08-21T08:37:22Z")

</div>

hi @benayat  
Are you looking for `cast_column("image", Image(decode=False))`?

Please see [Load image data](https://huggingface.co/docs/datasets/image_load#local-files) for example snippet.

```auto
from datasets import load_dataset, Image
dataset = load_dataset("chronopt-research/cropped-vggface2-224").cast_column("image", Image(decode=False))

```

---

<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:** [August 21, 2024, 8:37pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fturn-of-automatic-pil-image-generation-in-load-dataset%2F103222%2F3 "2024-08-21T20:37:48Z")

</div>

Closed on August 21, 2024, 8:37pm UTC

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