TorchVision 0.28 is out! This is a small release whose main change is the removal of the deprecated video decoding and encoding APIs (read_video, write_video, read_video_timestamps, VideoReader) from torchvision.io. Video decoding and encoding has fully migrated to TorchCodec as a part of our efforts to re-focus TorchVision. On the transforms side, v2.Resize now accepts string interpolation modes (e.g. "bilinear") and correctly honors NEAREST_EXACT on masks.
Backwards Incompatible Changes
-
Video decoding/encoding removed from
torchvision.io; migrated to TorchCodec (#9451)read_video,write_video,read_video_timestamps, andVideoReaderare no longer available in OSS torchvision, and the video-backed datasets now require TorchCodec. These APIs were deprecated (with warnings) in prior releases and are now gone.Symptoms you may hit:
ImportError: cannot import name 'read_video' from 'torchvision.io'import torchvision.io.videoraisingModuleNotFoundError/ImportError- From video datasets:
ImportError: Video decoding capabilities were removed from torchvision and migrated to TorchCodec. Please install TorchCodec following instructions at https://github.com/pytorch/torchcodec#installing-torchcodec
As an example, if you performed the following on TorchVision 0.27:
from torchvision.io import read_video frames, audio, info = read_video("video.mp4")
You would now achieve that with:
# pip install torchcodec from torchcodec.decoders import VideoDecoder decoder = VideoDecoder("video.mp4") frames = decoder[:] # or decoder.get_frames_in_range(...), etc.
See the TorchCodec documentation for tutorials and API references.
Improvements
- Allow passing
interpolationas a string (e.g."bilinear","nearest") in resize transforms, in addition to theInterpolationModeenum (#9461) tv_tensors.wrap()now preserves metadata for customTVTensorsubclasses — a subclass can define its own.wrap()method to control how it is re-wrapped (#9490)
Bug fixes
- Fix
F.resizeontv_tensors.Maskto honorNEAREST_EXACTinterpolation. Previously theinterpolationargument was ignored for mask inputs (resize_maskhardcodedNEAREST), soNEAREST_EXACTsilently produced plainNEARESToutput (#9497) - Fix a GIF decoder bug on malformed GIFs that could write outside the allocated tensor's memory (#9520)