Search code examples
pythonpytorchtorchvision

pytorchvideo.transforms.RandAugment import error


I am trying to run from pytorchvideo.transforms import RandAugment in Python, but it returns the following error:

ModuleNotFoundError: No module named 'torchvision.transforms.functional_tensor'

I can run import pytorchvideo just fine. I tried uninstalling and reinstalling both pytorchvideo and torchvision but the problem persists. Why would this happen?


Solution

  • TL;DR: Uninstall your pytorchvideo package and use the git version pip install git+https://github.com/facebookresearch/pytorchvideo. You need git installed. Or just download the repo, and run `pip install <repo_folder> locally.


    Basically, the pip package is old, very old. One year ago, there was a commit to remove the import in transforms.augmentations. The module which is not found is now deprecated. The module named functional_tensor was renamed _functional_tensor to mark the depreciation.

    Note from the install notice of torchvideo, there is a nightly version of the package. Although, the package is not very much "nightly" since the last update is 2 years old. It would be better to install a nightly package rather than the git package. But in my case, the build seems broken. pip is looping with some errors messages. Just note that using the repo as source might expose you to some unstabilities.