lama
lama copied to clipboard
Colab broken: LaMa-inpainting.ipynb
There needs to be some fixes for this to work, it is not working as of now with Python 3.10.
Most of the installer problems are solved with theese:
!pip install wldhx.yadisk-direct
!pip install --upgrade pip
!pip uninstall --yes --quiet osqp
!pip install -U scikit-survival
!pip uninstall kornia -y
!pip install kornia --no-dependencies
!pip install kornia-rs
!pip install pytorch-lightning
!pip install hydra-core
!pip install webdataset
But in the end I got stuck here. Loaded the image, masked it and finnish. Created mask, display mask image and image drawed on. Last part, do the inpainting crashes.
Run inpainting
Traceback (most recent call last):
File "/content/lama/bin/predict.py", line 32, in <module>
from saicinpainting.training.trainers import load_checkpoint
File "/content/lama/saicinpainting/training/trainers/__init__.py", line 3, in <module>
from saicinpainting.training.trainers.default import DefaultInpaintingTrainingModule
File "/content/lama/saicinpainting/training/trainers/default.py", line 10, in <module>
from saicinpainting.training.modules.fake_fakes import FakeFakesGenerator
File "/content/lama/saicinpainting/training/modules/fake_fakes.py", line 2, in <module>
from kornia import SamplePadding
ImportError: cannot import name 'SamplePadding' from 'kornia' (/usr/local/lib/python3.10/dist-packages/kornia/__init__.py)
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
[<ipython-input-12-f0997936e491>](https://localhost:8080/#) in <cell line: 60>()
58
59 plt.rcParams['figure.dpi'] = 200
---> 60 plt.imshow(plt.imread(f"/content/output/{fname.split('.')[1].split('/')[2]}_mask.png"))
61 _=plt.axis('off')
62 _=plt.title('inpainting result')
2 frames
[/usr/local/lib/python3.10/dist-packages/PIL/ImageFile.py](https://localhost:8080/#) in __init__(self, fp, filename)
107 if isPath(fp):
108 # filename
--> 109 self.fp = open(fp, "rb")
110 self.filename = fp
111 self._exclusive_fp = True
FileNotFoundError: [Errno 2] No such file or directory: '/content/output/yoloselfie_mask.png'
Solved by: (1) edit /content/lama/saicinpainting/training/modules/fake_fakes.py, change from kornia import SamplePadding to from kornia.constants import SamplePadding (2) if your colab does not have gpu (torch.cuda.is_available() return false), edit /content/lama/bin/predict.py, change device = torch.device(predict_config.device) (line 43) to device = torch.device("cpu")
I have the same problem but this solution doesn't help
Solved by: (1) edit /content/lama/saicinpainting/training/modules/fake_fakes.py, change from kornia import SamplePadding to from kornia.constants import SamplePadding (2) if your colab does not have gpu (torch.cuda.is_available() return false), edit /content/lama/bin/predict.py, change device = torch.device(predict_config.device) (line 43) to device = torch.device("cpu")
Traceback (most recent call last):
File "/content/lama/bin/predict.py", line 14, in
FileNotFoundError Traceback (most recent call last)
2 frames /usr/local/lib/python3.10/dist-packages/PIL/ImageFile.py in init(self, fp, filename) 103 if is_path(fp): 104 # filename --> 105 self.fp = open(fp, "rb") 106 self.filename = fp 107 self._exclusive_fp = True
FileNotFoundError: [Errno 2] No such file or directory: '/content/output/img_mask.png'
Copy_of_LaMa_inpainting.ipynb.zip
- Download my colab
- edit /content/lama/saicinpainting/training/modules/fake_fakes.py, you need to change from kornia import SamplePadding to from kornia.constants import SamplePadding
- edit /content/lama/bin/predict.py, you need to change device = torch.device(predict_config.device) (line 43) to device = torch.device("cpu")
Thank you very much! Finally, it works!
The solution above worked for me for some time but now I'm experiencing a new error:
Run inpainting
Traceback (most recent call last):
File "/content/lama/bin/predict.py", line 15, in
FileNotFoundError Traceback (most recent call last)
2 frames /usr/local/lib/python3.10/dist-packages/PIL/ImageFile.py in init(self, fp, filename) 103 if is_path(fp): 104 # filename --> 105 self.fp = open(fp, "rb") 106 self.filename = fp 107 self._exclusive_fp = True
FileNotFoundError: [Errno 2] No such file or directory: '/content/output/tourist_mask.png'
@MacM2Pro
Still work for me.
But !curl -L $(yadisk-direct https://disk.yandex.ru/d/ouP6l8VJ0HpMZg) -o big-lama.zip
The above link is broken, find this and replace it with:
!curl -LJO https://huggingface.co/smartywu/big-lama/resolve/main/big-lama.zip
@MacM2Pro
Still work for me.
But !curl -L $(yadisk-direct https://disk.yandex.ru/d/ouP6l8VJ0HpMZg) -o big-lama.zip
The above link is broken, find this and replace it with:
!curl -LJO https://huggingface.co/smartywu/big-lama/resolve/main/big-lama.zip
It worked for me.
Hi, I replaced the !curl -LJO https://huggingface.co/smartywu/big-lama/resolve/main/big-lama.zip and edited /content/lama/saicinpainting/training/modules/fake_fakes.py, you need to change from kornia import SamplePadding to from kornia.constants import SamplePadding.
However, it still not work for me. can you check is there any update?