Google Colab ToTensor2 albumentations

Hello, I tried to import ToTensor2 as a “from albumentations import ToTensor2” in colab, but it shows an error "cannot import name ‘ToTensor2’ from ‘albumentations’ " Could someone help?

1 Like

I guess you have a typo and want to use ToTensorV2?

Yes, but still i cannot fix it.

Hello, is there any solution for this problem?
I have tried

!pip install -q -U albumentations

import albumentations 
from albumentations.pytorch import ToTensorV2

and

!pip install albumentations==1.1.0
import albumentations 
from albumentations.pytorch import ToTensorV2

both of them do not work. Is there any other way to use albumenations ?

Thank you

Could you describe your issue with more details please, as:

!pip install albumentations
import albumentations
from albumentations.pytorch import ToTensorV2
albumentations.__version__
> '1.1.0'

works in my setup.

1 Like