Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The images of EMNIST() are flipped and rotated 90 degrees anticlockwise by default #8783

Open
hyperkai opened this issue Dec 5, 2024 · 1 comment

Comments

@hyperkai
Copy link

hyperkai commented Dec 5, 2024

🐛 Describe the bug

The images of EMNIST() are flipped and rotated 90 degrees anticlockwise by default as shown below:

from torchvision.datasets import EMNIST

train_data = EMNIST(
    root="data",
    split="byclass",
    train=True,
    download=True,
)

test_data = EMNIST(
    root="data",
    split="byclass",
    train=False,
    download=True
)

import matplotlib.pyplot as plt

def show_images(data):
    plt.figure(figsize=(10, 5))
    col = 5
    for i, (image, label) in enumerate(data, 1):
        plt.subplot(1, col, i)
        plt.title(label)
        plt.axis('off')
        plt.imshow(image)
        if i == col:
            break
    plt.show()

show_images(data=train_data)
show_images(data=test_data)

Screenshot 2024-12-05 091144

Versions

import torchvision

torchvision.__version__ # '0.20.1'
@NicolasHug
Copy link
Member

Thanks for the report @hyperkai .

From https://www.westernsydney.edu.au/__data/assets/text_file/0019/1204408/EMNIST_Readme.txt I'm reading (emphasis mine):

The dataset is provided in two file formats. Both versions of the dataset contain identical information, and are provided entirely for the sake of convenience. The first dataset is provided in a Matlab format that is accessible through both Matlab and Python (using the scipy.io.loadmat function). The second version of the dataset is provided in the same binary format as the original MNIST dataset as outlined in http://yann.lecun.com/exdb/mnist/

Looking at our code, we are using the latter format, and we're using the exact same code to read EMNIST as for reading MNIST, which would suggest that this orientation was in fact originally intended. Am I missing anything obvious?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants