transforms.functional.resize broken for (h,w) tensors
Open
Nobody has claimed this yet.
module: documentation
module: transforms
needs discussion
- Dominant language
- Python
- Stars
- 17.9k
- Forks
- 7.3k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 13
Description
🐛 Describe the bug
torchvision version: linux condaforge '0.13.1+cu113'
import torch
import torchvision
# Breaks
"""
ValueError: Input and output must have the same number of spatial dimensions, but got input with with spatial dimensions of [640] and output size of [960, 1280]. Please provide input tensor in (N, C, d1, d2, ...,dK) format and output size in (o1, o2, ...,oK) format.
"""
a = torch.zeros((480, 640))
a = torchvision.transforms.functional.resize(a, (2 * 480, 2 * 640))
print(a.shape)
# Works
b = torch.zeros((480, 640))
b = b.unsqueeze(0)
print(b.shape)
b = torchvision.transforms.functional.resize(b, (2 * 480, 2 * 640))
print(b.shape)
Versions
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
cc @vfdev-5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the torchvision.transforms.functional.resize entry point and run the issue's two tensor examples to reproduce the differing behavior. Check the existing resize handling for a two-dimensional (h, w) tensor; done means the first example resizes successfully to the expected dimensions without requiring an added dimension.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100