From bfca57cce69d579f15debc77478e46fadb312a06 Mon Sep 17 00:00:00 2001 From: Yasser Souri Date: Tue, 7 Sep 2021 20:29:25 +0200 Subject: [PATCH] Fix edge case issue in `uniform_temporal_sampling` --- pytorchvideo/transforms/functional.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytorchvideo/transforms/functional.py b/pytorchvideo/transforms/functional.py index e848a159..d43d1715 100644 --- a/pytorchvideo/transforms/functional.py +++ b/pytorchvideo/transforms/functional.py @@ -37,7 +37,7 @@ def uniform_temporal_subsample( assert num_samples > 0 and t > 0 # Sample by nearest neighbor interpolation if num_samples > t. indices = torch.linspace(0, t - 1, num_samples) - indices = torch.clamp(indices, 0, t - 1).long() + indices = torch.clamp(indices, 0, t - 1).round().long() return torch.index_select(x, temporal_dim, indices)