Skip to content

image column not automatically inferred if image dataset only contains 1 image #6545

@apolinario

Description

@apolinario

Describe the bug

By default, the standard Image Dataset maps out file_name to image when loading an Image Dataset.

However, if the dataset contains only 1 image, this does not take place

Steps to reproduce the bug

Input
(dataset with one image multimodalart/repro_1_image)

from datasets import load_dataset
dataset = load_dataset("multimodalart/repro_1_image")
dataset

Output:

DatasetDict({
    train: Dataset({
        features: ['file_name', 'prompt'],
        num_rows: 1
    })
})

Input
(dataset with 2+ images multimodalart/repro_2_image)

from datasets import load_dataset
dataset = load_dataset("multimodalart/repro_2_image")
dataset

Output:

DatasetDict({
    train: Dataset({
        features: ['image', 'prompt'],
        num_rows: 2
    })
})

Expected behavior

Expected to map file_nameimage for all dataset sizes, including 1.

Environment info

Both latest main and 2.16.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions