Skip to content

Dataset images with incorrect orientation #1

@Phonicavi

Description

@Phonicavi

Hi,

I've noticed that several images in huggingface datasets are rotated (90°/180°/270°), is that a bug or a feature?

Dataset used:
https://huggingface.co/datasets/Cusyoung/SpaCE-10

Rotations observed on a random sample.
Code used:

from PIL import Image, ImageOps
from datasets import load_dataset
import io

def decode_bytes(x: str):
    return Image.open(io.BytesIO(x))

def visualize(row: Dict) -> None:
    images = [decode_bytes(x) for x in row['image']]
    row.pop('image')
    print(json.dumps(row, indent=2))
    plt.close()
    _, ax = plt.subplots(4, 2, figsize=(16, 20))
    for idx, img in enumerate(images):
        ax[idx % 4][idx // 4].imshow(img)
    plt.show()

ds = load_dataset("/path/to/huggingface/datasets/Cusyoung/SpaCE-10/single-choice/sp", split='test')

sample = ds[76]
visualize(sample)

Also, img.getexif() shows empty, and ImageOps.exif_transpose(img) does not work for missing exif image.
How can I get the original EXIF to verify orientation?

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