【问题标题】: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

    【讨论】:

      猜你喜欢
      • 2020-11-02
      • 1970-01-01
      • 2021-12-08
      • 2019-11-27
      • 2015-02-05
      • 2019-12-19
      • 1970-01-01
      • 2019-12-30
      相关资源
      最近更新 更多