Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot fix ImportError: cannot import name 'ToTensorV2' from 'albumentations.pytorch' on Colab

I tried all three solutions from this question to solve the problem, but still receive an error:

ImportError: cannot import name 'ToTensorV2' from 'albumentations.pytorch' (/usr/local/lib/python3.7/dist-packages/albumentations/pytorch/__init__.py)

My current code:

!pip install -U albumentations
import albumentations 
from albumentations.pytorch import ToTensorV2
like image 404
Anakin Skywalker Avatar asked Jan 25 '23 09:01

Anakin Skywalker


1 Answers

Have you tried factory resetting the runtime? If you haven't, maybe python was still loading the earlier version. I have just tested the accepted solution from the linked question on a fresh colab instance and it worked fine:

!pip install albumentations==0.4.6
import albumentations 
from albumentations.pytorch import ToTensorV2
like image 160
yutasrobot Avatar answered Jan 31 '23 01:01

yutasrobot