lucidrains / lightweight-gan

Implementation of 'lightweight' GAN, proposed in ICLR 2021, in Pytorch. High resolution image generations that can be trained within a day or two
MIT License
1.62k stars 220 forks source link

[Colab] cannot import name 'filter2d' from 'kornia' #102

Open katongo opened 2 years ago

katongo commented 2 years ago

Hi

Training on google Colab Pro, I started getting this error:

Traceback (most recent call last): File "/usr/local/bin/lightweight_gan", line 5, in from lightweight_gan.cli import main File "/usr/local/lib/python3.7/dist-packages/lightweight_gan/init.py", line 1, in from lightweight_gan.lightweight_gan import LightweightGAN, Generator, Discriminator, Trainer, NanException File "/usr/local/lib/python3.7/dist-packages/lightweight_gan/lightweight_gan.py", line 25, in from kornia import filter2d ImportError: cannot import name 'filter2d' from 'kornia' (/usr/local/lib/python3.7/dist-packages/kornia/init.py)

Before that everything worked fine for several weeks

arturocalvoacn commented 2 years ago

It seems to be connected with the release 0.6.1 on Kornia (Oct 22nd), where they refactored the library namespaces. https://github.com/kornia/kornia/pull/1412/commits/218232ca3645693b0b50aca5bde498dce49dadd3#

I think filter2d is now under kornia.filters instead of directly under kornia. This causes the training and generation functions of lightweightGAN to crash.

In the meantime you can continue training / generating by reverting to the previous release on Kornia: pip install kornia==0.5.4

FYI @lucidrains

katongo commented 2 years ago

Thank you @arturocalvoacn. Indeed downgrading to kornia 0.5.4 fixes the issue. I guess a fix in the project imports or dependencies is still required

CaptainStabs commented 2 years ago

This was fixed with the latest release

domef commented 2 years ago

I'm having the same problem, I fixed it by changing https://github.com/lucidrains/lightweight-gan/blob/fce20938562a0cc289c915f7317722a8241abd37/lightweight_gan/lightweight_gan.py#L25 in from kornia.filters import filter2d.