Inconsistent results of VideoReader get_batch function for avi files
- Dominant language
- C++
- Stars
- 2.5k
- Forks
- 232
- PR merge metrics
- No merged PRs in 30d
Description
### Description
Function get_batch in VideoReader returns inconsistent results, with a 1% probability when reading avi files from HMDB51 dataset.
### System
macOS Big Sur + python 3.7 + decord 0.6.0
### Code
File `Parkour_Dive_Tutorial_somersault_f_cm_np1_ba_bad_3.avi` can be found in HMDB51 dataset. Well, not only this file :(
``` python
import numpy as np
import torch
import torch.utils.dlpack as dlpack
from decord import VideoReader
import decord
decord.bridge.set_bridge('torch')
def read(i):
vr = VideoReader("Parkour_Dive_Tutorial_somersault_f_cm_np1_ba_bad_3.avi")
decode_list = torch.from_numpy(np.asarray([0, 4, 8, 12, 16, 21, 25, 29, 33, 37, 38, 38, 38, 38, 38, 38]))
batch = vr.get_batch(decode_list)
mean = batch.float().mean().item()
if mean != 141.47889709472656:
print(i, mean)
del vr
for i in range(1000):
read(i)
```
### Result
``` txt
472 141.70274353027344
535 141.70274353027344
546 141.70274353027344
608 141.70274353027344
623 141.70274353027344
627 141.70274353027344
643 141.70274353027344
748 141.70274353027344
836 141.70274353027344
873 141.70274353027344
885 141.70274353027344
```
### Others
If get_batch for np.arange(0, 39) and get valid frames by decode_list, the results will be consistent.
``` python
import numpy as np
import torch
import torch.utils.dlpack as dlpack
from decord import VideoReader
import decord
decord.bridge.set_bridge('torch')
def read(i):
vr = VideoReader("Parkour_Dive_Tutorial_somersault_f_cm_np1_ba_bad_3.avi")
full_decode_list = np.arange(0, 39)
decode_list = torch.from_numpy(np.asarray([0, 4, 8, 12, 16, 21, 25, 29, 33, 37, 38, 38, 38, 38, 38, 38]))
full_batch = vr.get_batch(full_decode_list)
batch = full_batch[decode_list]
mean = batch.float().mean().item()
if mean != 141.47889709472656:
print(i, mean)
del vr
for i in range(1000):
read(i)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.