ImageFolder mode of the Image

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.

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!

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

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!

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

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

1 Like