Repository navigation
Conversation
The torchvision.io.decode_image function is deprecated in favor of TorchCodec. This change updates beginner_source/basics/data_tutorial.py to use torchcodec.decoders.decode_image instead. The change maintains API compatibility as TorchCodec's decode_image accepts the same arguments (file path) and returns tensors in the same format (CHW uint8 by default). Also adds torchcodec to requirements.txt to ensure it is available during builds. Fixes pytorch#3978
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/3979
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Hi @hippi345! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:
Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows. |
1 similar comment
|
The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:
Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows. |
Replace deprecated torchvision decode_image with TorchCodec
Summary
This PR addresses issue #3978 by replacing the deprecated
torchvision.io.decode_imagefunction withtorchcodec.decoders.decode_imagein the Datasets & DataLoaders tutorial.Changes
beginner_source/basics/data_tutorial.py: Changed import fromtorchvision.io.decode_imagetotorchcodec.decoders.decode_image.ci/docker/requirements.txt: AddedtorchcodecdependencyBackground
Starting with recent versions of torchvision, the
decode_imagefunction has been deprecated in favor of TorchCodec, which is now the recommended way to decode images in the PyTorch ecosystem. The function's documentation explicitly states:Technical Details
The change maintains full API compatibility:
decode_imageaccepts the same arguments (file path as string)The tutorial code continues to work exactly as before, just using the non-deprecated API.
Testing
Verified that the fix works correctly:
torchcodec.decoders.decode_imagesucceedsCustomImageDatasetclass with sample imagesAll functionality is preserved and the deprecation warning is eliminated.
Fixes #3978