Skip to content

transforms.functional.resize broken for (h,w) tensors #7293

Open
@gtangg12

Description

@gtangg12

🐛 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions