KeremTurgutlu / self_supervised

Implementation of popular SOTA self-supervised learning algorithms as Fastai Callbacks.
Apache License 2.0
318 stars 33 forks source link

ImportError: cannot import name 'augmentation' from 'kornia.augmentation' #72

Closed jimmiemunyi closed 2 years ago

jimmiemunyi commented 2 years ago

Please confirm your versions of fastai, timm, kornia, fastcore, and nbdev prior to reporting a bug

fastai - 2.5.3 timm - 0.5.4 kornia - 0.6.3 fastcore - 1.3.27 nbdev - 1.1.23

Describe the bug Cannot get past the imports, I get the error ImportError: cannot import name 'augmentation' from 'kornia.augmentation' I installed the package as advised, pip install self-supervised. I am actually running the tutorials on your documentation as they are in Colab

To Reproduce Steps to reproduce the behavior:

  1. pip install -Uqq self-supervised
  2. The necessary import:

from self_supervised.augmentations import from self_supervised.layers import from self_supervised.vision.simclr import *


**Expected behavior**
Import successful

**Error with full stack trace**

Place between these lines with triple backticks:

ImportError Traceback (most recent call last) in () ----> 1 from self_supervised.augmentations import 2 from self_supervised.layers import 3 from self_supervised.vision.simclr import *

/usr/local/lib/python3.7/dist-packages/self_supervised/augmentations.py in () 6 # Cell 7 from fastai.vision.all import * ----> 8 from kornia.augmentation import augmentation as korniatfm 9 import torchvision.transforms as tvtfm 10 import kornia

ImportError: cannot import name 'augmentation' from 'kornia.augmentation' (/usr/local/lib/python3.7/dist-packages/kornia/augmentation/init.py)



**Additional context**
Add any other context about the problem here.
jimmiemunyi commented 2 years ago

I solved this issue by editing the file: self-supervised/augmentation.py

I changed this line: from kornia.augmentation import augmentation as korniatfm

to import kornia.augmentations as korniatfm

jimmiemunyi commented 2 years ago

I will try and submit a PR

Theivaprakasham commented 2 years ago

Running !pip install kornia==0.5.2 fixed the issue for me.

KeremTurgutlu commented 2 years ago

Thanks for all your attention. We fixed the issue in https://github.com/KeremTurgutlu/self_supervised/pull/73 and had a new release https://github.com/KeremTurgutlu/self_supervised/releases/tag/v.1.0.4 which is pushed pypi repository. Now pip install self-supervised should work without issues.