Datasets:
Tasks:
Image Classification
Modalities:
Image
Formats:
parquet
Sub-tasks:
multi-class-image-classification
Languages:
English
Size:
1M - 10M
ArXiv:
License:
How to use the parquet files?
#39
by
tian1327
- opened
Hi,
Could anyone please provide instructions on how to utilize the parquet files to access the raw image files? I remember that the images were previously provided in zip files, but now they are in parquet files. Can we still access the PNG files through it?
I would appreciate your help! Thank you!
Yes you can, e.g. this will save all the images in a directory of your choice
from pathlib import Path
from datasets import load_dataset, Image
# Login using e.g. `huggingface-cli login` to access this dataset
ds = load_dataset("ILSVRC/imagenet-1k", split="train")
ds = ds.cast_column("image", Image(decode=False))
output_dir = Path("path/to/output/dir")
for image in ds["image"]:
(output_dir / image["path"]).write_bytes(image["bytes"])
Note that we use Image(decode=False) do access the image path name and bytes instead of getting PIL.Image objects