pytorch / pytorch/vision

Allow for arbitrary sequences in torchvision/transforms/functional

Open
#5,398 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

🚀 The feature

Replace all checks for (list,tuple) in functional with Iterable.

Motivation, pitch

There are about 8 checks in functional right now which requires the argument to be either list or tuple, e.g.
https://github.com/pytorch/vision/blob/main/torchvision/transforms/functional.py#L1059
Instead of performing these checks, simply checking for Iterable allows to use e.g. numpy arrays.

In my usecase i generate parameters using numpy, and I don't want to convert them.

The documentation indicates that general sequences should work, so the current checks are counter-intuitive.

Alternatives

No response

Additional context

No response

cc @vfdev-5 @datumbox

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 in torchvision/transforms/functional.py at the check near line 1059, then locate the other checks that only accept lists or tuples. Replace the restrictive checks with Iterable-based handling so numpy arrays and other general sequences are accepted, and verify the existing functional transform tests cover the changed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
computer-vision
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.