diff --git a/torchvision/io/video_reader.py b/torchvision/io/video_reader.py index 7dfeb1ce464..69f7f1e016b 100644 --- a/torchvision/io/video_reader.py +++ b/torchvision/io/video_reader.py @@ -192,9 +192,9 @@ def __next__(self) -> Dict[str, Any]: frame = next(self._c) pts = float(frame.pts * frame.time_base) if "video" in self.pyav_stream: - frame = torch.tensor(frame.to_rgb().to_ndarray()).permute(2, 0, 1) + frame = torch.as_tensor(frame.to_rgb().to_ndarray()).permute(2, 0, 1) elif "audio" in self.pyav_stream: - frame = torch.tensor(frame.to_ndarray()).permute(1, 0) + frame = torch.as_tensor(frame.to_ndarray()).permute(1, 0) else: frame = None except av.error.EOFError: