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

Broken reading for some GIFs #9009

Open
abionics opened this issue Mar 28, 2025 · 0 comments
Open

Broken reading for some GIFs #9009

abionics opened this issue Mar 28, 2025 · 0 comments
Labels

Comments

@abionics
Copy link

abionics commented Mar 28, 2025

🐛 Describe the bug

I have encountered an issue where using torchvision.io.read_image (as well as decode_image and decode_gif) on certain GIF files produces an invalid output. Here is a code:

import cv2
from torchvision.io import read_image

gif = read_image('sample.gif').numpy().transpose(0, 2, 3, 1)
image = gif[15]  # 15-th frame

image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
cv2.imshow('read_torch', image)
cv2.waitKey()

Sample of buggy GIF:
Image
Its source: https://i.pinimg.com/originals/a0/02/a3/a002a3e51a2adc85d6c0a4684892e743.gif

Output:
Image

Comparing with PIL (Pillow)

Image

I understand that this may be an underlying issue of GIFLIB and will not be fixed. However, since the behavior is unexpected and could impact users, it might be beneficial to include a note in the docs.

Versions

I found this behavior on Macbook and Linux server. They have different setup, but both of them use the latest versions:

torch==2.6.0
torchvision==0.21.0
@NicolasHug NicolasHug added the bug label Apr 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants