pytorch / pytorch/vision

Error while using RandomResizedCropVideo

Open
#1,385 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug module: transforms module: video
Dominant language
Python
Stars
17.9k
Forks
7.3k
Avg merge
1d 15h
Merged PRs (30d)
13

Description

I started using the new video transformations by downloading the video transformations source code (seems like it doesn't appear when trying to upgrade via pip).

The transformation I'm trying to use is:

def build_transforms():
    mean = [0.485, 0.456, 0.406]
    std = [0.229, 0.224, 0.225]
    res = transforms.Compose([transforms_video.ToTensorVideo(),
                              transforms_video.RandomResizedCropVideo(224),
                              transforms_video.RandomHorizontalFlipVideo(),
                              transforms_video.NormalizeVideo(mean=mean, std=std)
                              ])

    return res

This composition raises an error while trying to transform a video clip (It doesn't happen if I remove transforms_video.RandomResizedCropVideo(224)):

TypeError: Caught TypeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/home/ekosman/anaconda3/envs/torch/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/ekosman/anaconda3/envs/torch/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/ekosman/anaconda3/envs/torch/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/workdisk/action_start_detection/loaders/torch_data_loader_no_bg.py", line 284, in __getitem__
    video = self.transform_clip(video)
  File "/workdisk/action_start_detection/loaders/torch_data_loader_no_bg.py", line 157, in transform_clip
    clip = self.transform(clip)
  File "/home/ekosman/anaconda3/envs/torch/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 61, in __call__
    img = t(img)
  File "/workdisk/action_start_detection/utils/transforms_video.py", line 78, in __call__
    i, j, h, w = self.get_params(clip, self.scale, self.ratio)
  File "/home/ekosman/anaconda3/envs/torch/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 638, in get_params
    area = img.size[0] * img.size[1]
TypeError: 'builtin_function_or_method' object is not subscriptable

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the video transformation implementation around transforms_video.py line 78, then compare its get_params call with torchvision/transforms/transforms.py. Reproduce the RandomResizedCropVideo(224) failure in the reported Compose pipeline and trace the clip shape and type reaching the crop transform. Done means the transform runs without the reported TypeError while preserving the behavior of the other listed video transforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
computer-vision
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.