Datasets:

Modalities:
Image
Text
Formats:
parquet
ArXiv:
Libraries:
Datasets
Dask

how to extract the image?

#9
by jucic - opened

I download the dataset, and the images data looks like this(the screenshot ), how to extract the image? I saved it to 'images.txt' but fails to extract the image with the code below.

from PIL import Image
import io
with open('images.txt', 'rb') as f:
bytes_io = io.BytesIO(f.read())
img = Image.open(bytes_io)

image.png

from PIL import Image
import daft
from daft import DataType as dt
from io import BytesIO

df = daft.read_parquet('hf://datasets/HuggingFaceM4/the_cauldron/ai2d/train-00000-of-00001-2ce340398c113b79.parquet').collect()
df = df.with_column("image_materialized",df["images"].apply(
lambda x: Image.open(BytesIO(x[0].get("bytes"))),
return_dtype=dt.image()
)).collect()
df.show()

Sign up or log in to comment