【问题标题】:Cannot fix ImportError: cannot import name 'ToTensorV2' from 'albumentations.pytorch' on Colab无法修复 ImportError:无法从 Colab 上的“albumentations.pytorch”导入名称“ToTensorV2”
【发布时间】:2021-07-13 01:38:01
【问题描述】:
我尝试了this question 的所有三种解决方案来解决问题,但仍然收到错误:
ImportError: cannot import name 'ToTensorV2' from 'albumentations.pytorch' (/usr/local/lib/python3.7/dist-packages/albumentations/pytorch/__init__.py)
我当前的代码:
!pip install -U albumentations
import albumentations
from albumentations.pytorch import ToTensorV2
【问题讨论】:
标签:
pip
pytorch
google-colaboratory
【解决方案1】:
您是否尝试过将运行时恢复出厂设置?如果你还没有,也许 python 仍在加载早期版本。我刚刚在一个新的 colab 实例上测试了链接问题中接受的解决方案,它运行良好:
!pip install albumentations==0.4.6
import albumentations
from albumentations.pytorch import ToTensorV2
【解决方案2】:
这对我有用。从github导入没有任何问题。
!pip install -U git+https://github.com/albu/albumentations > /dev/null && echo import albumentations from albumentations.pytorch import ToTensorV2