Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

functional_tensor not found #533

Closed
sdlpkxd opened this issue May 27, 2022 · 8 comments · May be fixed by #624
Closed

functional_tensor not found #533

sdlpkxd opened this issue May 27, 2022 · 8 comments · May be fixed by #624

Comments

@sdlpkxd
Copy link

sdlpkxd commented May 27, 2022

when I run training code, it reports ModuleNotFoundError: No module named 'torchvision.transforms.functional_tensor'

my environment:
Mac M1 chip
python 3.9
torch 1.10.2
torchvision 0.2.2

Should torchvision.transforms.functional_tensor be torchvision.transforms.functional ?
Need help

@ssube
Copy link

ssube commented Apr 15, 2023

I am also encountering this after upgrading to PyTorch 2.x. Based on checking a few venvs, it looks like torchvision.transforms.functional_tensor was available up through 0.14.1 but is not present in 0.15.0 or better.

@kamyker
Copy link

kamyker commented Apr 17, 2023

Works for me but i get:

The torchvision.transforms.functional_tensor module is deprecated in 0.15 and will be removed in 0.17. Please don't rely on it. You probably just need to use APIs in torchvision.transforms.functional or in torchvision.transforms.v2.functional.

@gordon0907
Copy link

I'm also having this warning. As I searched in the repo, torchvision.transforms.functional_tensor is only called in "basicsr/data/degradations.py". Replacing the import line torchvision.transforms.functional_tensor in this file, with torchvision.transforms.functional should solve the warning problem.

Environment:
macOS 13.4 (Apple M1 Max)
Python 3.10.11
torch 2.0.1
torchvision 0.15.2

@shun-lin
Copy link

Looks like this package is not updated anymore, to patch the issue in your python program you may add those lines

from torchvision.transforms import functional
import sys

sys.modules["torchvision.transforms.functional_tensor"] = functional

which will redirect torchvision.transforms.functional_tensor to torchvision.transforms.functional so the broken import will now work again w/ latest torchvision.

@sdlpkxd
Copy link
Author

sdlpkxd commented Feb 25, 2024

Yea, using torchvision.transforms.functional instread of torchvision.transforms.functional_tensor is recommended for the latest torchvision

@bedbad
Copy link

bedbad commented Jun 20, 2024

Why do users have to patch those every time?
This is definetely not solved. If the package is not updated anymore - change a maintaner or release managed fork
The package is used.

@lightandshadow68
Copy link

This is not a solution when BasicSR is used as a dependency in a library. Nor can I patch a file as part of an automated test suite.

@lightandshadow68
Copy link

I am also encountering this after upgrading to PyTorch 2.x. Based on checking a few venvs, it looks like torchvision.transforms.functional_tensor was available up through 0.14.1 but is not present in 0.15.0 or better.

It has been deprecated for some time now, and was eventually removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants