facebookresearch / facebookresearch/SlowFast

NumPy array not writable error in slowfast/datasets/decoder.py when using torchvision backend. "np.array" typecasting required

Open
#629 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
7.4k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

When using torchvision backend I receive the error:
> /home/alp/Desktop/slowfast-with-torchvision/SlowFast/slowfast/datasets/decoder.py:273: UserWarning: The given NumPy array is not writable, and PyTorch does not support non-writable tensors. This means writing to this tensor will result in undefined behavior. You may want to copy the array to protect its data or make it writable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at /opt/conda/conda-bld/pytorch_1666642991888/work/torch/csrc/utils/tensor_numpy.cpp:199.)

I am using
- pytorch=1.13.0
- torchvision=0.14.0
- ffmpeg=4.2

In order to fix this problem, the [line](https://github.com/facebookresearch/SlowFast/blob/5b5d9ecb15a54188943af0cbf5f7c420d8409018/slowfast/datasets/decoder.py#L273), should be fixed to:
`video_tensor = torch.from_numpy(np.frombuffer(np.array(video_handle), dtype=np.uint8))`

When I made the above change, I no longer receive the warning.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.