Clip samplers crash on iteration when no video clips are available
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
UniformClipSampler と RandomClipSampler クラスから始めてください。ここでは、空の可能性があるインデックスのリストに対して torch.cat が呼び出されています。短い動画をどのようにスキップするかについては VideoClips を確認してください。issue の再現スクリプトを実行し、各サンプラーで ValueError が発生することを確認してください。完了の条件は、4つのサンプラーと空入力の組み合わせがすべて例外なく [] を返すことと、短い動画と空の動画の両方をリグレッションテストで網羅することです。報告者は PR を作成する予定だと述べているため、作業を始める前に既存の PR がないか確認してください。
索引モデルが issue の本文から書いたものです。
説明
🐛 Describe the bug
UniformClipSampler reports length zero but raises an exception when every video is shorter than clip_length_in_frames. VideoClips warns that these videos will be skipped, so iterating the sampler should produce no indices.
Both UniformClipSampler and RandomClipSampler also fail when the video list is empty (for example, after VideoClips.subset([])). Both failures come from calling torch.cat(idxs) with an empty list.
Reproduction using precomputed timestamps, without video files or a decoder:
import torch
from torchvision.datasets.samplers import RandomClipSampler, UniformClipSampler
from torchvision.datasets.video_utils import VideoClips
for frame_counts in ([4], []):
paths = [f"video_{i}.mp4" for i in range(len(frame_counts))]
clips = VideoClips(
paths,
clip_length_in_frames=5,
frames_between_clips=5,
_precomputed_metadata={
"video_paths": paths,
"video_pts": [torch.arange(n) for n in frame_counts],
"video_fps": [30.0] * len(paths),
},
)
for sampler_cls in (UniformClipSampler, RandomClipSampler):
sampler = sampler_cls(clips, 3)
print(frame_counts, sampler_cls.__name__, "length:", len(sampler))
try:
print(list(sampler))
except ValueError as error:
print(type(error).__name__ + ": " + str(error))
Observed (in addition to the expected short-video warning):
[4] UniformClipSampler length: 0
ValueError: torch.cat(): expected a non-empty list of Tensors
[4] RandomClipSampler length: 0
[]
[] UniformClipSampler length: 0
ValueError: torch.cat(): expected a non-empty list of Tensors
[] RandomClipSampler length: 0
ValueError: torch.cat(): expected a non-empty list of Tensors
Expected: all four samplers yield [], consistent with their lengths. This also affects iteration through DistributedSampler wrapping these clip samplers.
I have a small fix and regression tests prepared and will submit a PR. Searches for both sampler names and empty-clip sampling did not find an existing report or competing fix.
Versions
- Torchvision source:
mainat134f6382956071833f05f072763c03f9858453f2(0.30.0a0+134f638), built locally with native ops. - PyTorch:
2.16.0.dev20261102 - Python:
3.13.3 - macOS 27.2, arm64; CPU reproduction.
- 主要言語
- Python
- スター
- 18k
- フォーク
- 7.3k
- 平均マージ
- 1時間
- マージ済み PR(30日)
- 3
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pytorch/vision のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
[detection] Faster R-CNN accepts negative box_detections_per_img and applies Python slicing対応中かも @hparik11 が 6 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
pytorch/vision#9761 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
sigmoid_focal_loss gives NaN gradients for confident predictions when gamma < 1対応中かも @yuvraj-del が 21 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
pytorch/vision#9743 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
vision_stable.cpp gets hipified into a duplicate copy under ROCm, causing "multiple definition of vision::cuda_version()"対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンmodule: rocm
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
complete_box_iou_loss / complete_box_iou: NaN gradients for zero-height boxes, NaN for point boxes対応中かも @aounullah が 21 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
pytorch/vision#9730 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 69/100
anderspitman/awesome-tunneling#330 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
521xueweihan/HelloGitHub#4676 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 18 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
pandas-dev/pandas-stubs#2155 ·
メンテナーはふだん 1 日以内に返信
-
essreduce
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
メンテナーはふだん 1 日以内に返信