我尝试了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发布于 2021-04-19 07:36:48
你有没有尝试过工厂重置运行时?如果没有,也许python还在加载较早的版本。我刚刚在一个新的colab实例上测试了链接问题中接受的解决方案,它工作得很好:
!pip install albumentations==0.4.6
import albumentations
from albumentations.pytorch import ToTensorV2发布于 2021-11-20 11:18:11
在这里,它对我很有效。从github导入没有任何问题。
!pip install -U git+https://github.com/albu/albumentations > /dev/null && echo import albumentations from albumentations.pytorch import ToTensorV2
https://stackoverflow.com/questions/67152132
复制相似问题