Sanster / IOPaint

Image inpainting tool powered by SOTA AI Model. Remove any unwanted object, defect, people from your pictures or erase and replace(powered by stable diffusion) any thing on your pictures.
https://www.iopaint.com/
Apache License 2.0
19.57k stars 2k forks source link

How to update to v1 from One Click Installer #257

Open Tobe2d opened 1 year ago

Tobe2d commented 1 year ago

I run win_config.bat and activated the new plugins however i get this error: ERROR | lama_cleaner.plugins.base_plugin:init:8 - RealESRGAN is not installed, please install it first. pip install realesrgan

How to install pip install realesrgan in the same env? to keep things clean as I dont wan to just install those add-ons on the main python.

Sanster commented 1 year ago

You can change the corresponding section in win_config.bat to the following lines:

@call conda install -y -c conda-forge cudatoolkit=11.7
@call pip3  install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117
@call pip3 install xformers
@call pip3 install -U lama-cleaner
@call lama-cleaner --install-plugins-package
Tobe2d commented 1 year ago

Thanks for the reply @Sanster

I have done that and now when I run win_start.bat I get this error:

lama-cleaner: error: torch.cuda.is_available() is False, please use --device cpu or check your pytorch installation
Press any key to continue . . .

If you are intersted in the full log here it is:

- Platform: Windows-10-10.0.22621-SP0
- Python version: 3.10.6
- torch: 1.13.1
- Pillow: 9.4.0
- diffusers: 0.14.0
- transformers: 4.25.1
- opencv-python: 4.7.0.68
- xformers: 0.0.18
- accelerate: 0.15.0
- lama-cleaner: 1.0.1

2023-04-02 05:45:42.039 | INFO     | lama_cleaner.parse_args:parse_args:169 - Loading installer config from E:\lama-cleaner\win_start.bat\..\installer_config.json
usage: lama-cleaner [-h] [--host HOST] [--port PORT] [--config-installer] [--load-installer-config]
                    [--installer-config INSTALLER_CONFIG]
                    [--model {lama,ldm,zits,mat,fcf,sd1.5,anything4,realisticVision1.4,cv2,manga,sd2,paint_by_example,instruct_pix2pix}]
                    [--no-half] [--cpu-offload] [--disable-nsfw] [--sd-cpu-textencoder] [--sd-controlnet]
                    [--sd-local-model-path SD_LOCAL_MODEL_PATH] [--local-files-only] [--enable-xformers]
                    [--device {cuda,cpu,mps}] [--gui] [--no-gui-auto-close] [--gui-size GUI_SIZE GUI_SIZE]
                    [--input INPUT] [--output-dir OUTPUT_DIR] [--model-dir MODEL_DIR] [--disable-model-switch]
                    [--quality QUALITY] [--enable-interactive-seg] [--enable-remove-bg] [--enable-realesrgan]
                    [--realesrgan-device {cpu,cuda,mps}]
                    [--realesrgan-model {realesr-general-x4v3,RealESRGAN_x4plus,RealESRGAN_x4plus_anime_6B}]
                    [--enable-gfpgan] [--gfpgan-device {cpu,cuda,mps}] [--enable-restoreformer]
                    [--restoreformer-device {cpu,cuda,mps}] [--enable-gif] [--install-plugins-package]
lama-cleaner: error: torch.cuda.is_available() is False, please use --device cpu or check your pytorch installation
Press any key to continue . . .
Sanster commented 1 year ago

I'm not sure why it has become a cpu version of torch, you can create a new bat file next to win_config and update torch separately

@echo off

set PATH=C:\Windows\System32;%PATH%

@call installer\Scripts\activate.bat

@call conda-unpack

@call conda install -y -c conda-forge cudatoolkit=11.7
@call pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117
PAUSE
Tobe2d commented 1 year ago

I created new .bat file and added the code above. When I run it it show this:

Traceback (most recent call last):
  File "E:\Ai__Project\lama-cleaner\installer\Scripts\conda-unpack-script.py", line 226, in <module>
    update_prefix(os.path.join(new_prefix, path), new_prefix,
  File "E:\Ai__Project\lama-cleaner\installer\Scripts\conda-unpack-script.py", line 66, in update_prefix
    with open(path, 'rb+') as fh:
FileNotFoundError: [Errno 2] No such file or directory: 'E:\\Ai__Project\\lama-cleaner\\installer\\Library\\bin\\libcrypto-1_1-x64.dll.c~.conda_trash'

And now when I run win_start.bat i get this:

image

After that it did download few things and start and yes it work ;-)

Howevere, whenever I start win_start.bat i get this:

image

Sanster commented 1 year ago

You can create a new bat file next to win_config to fix xformers error

@echo off

set PATH=C:\Windows\System32;%PATH%

@call installer\Scripts\activate.bat

@call conda-unpack

@call pip3 install xformers==0.0.16

PAUSE

The torch becomes the cpu version and the xformer error is due to the installation of xformers==0.0.18 which depend on torch 2.0, I was using an old python pypi source to do test so I didn't find this problem.

Tobe2d commented 1 year ago

Maybe new one click installer is the soulution?

Sanster commented 1 year ago

There is no need to re-download installer, if you are concerned that the current installer environment is messed up, you can unzip the zip package again and replace the contents of win_config.bat with the following:

@echo off

set PATH=C:\Windows\System32;%PATH%

@call installer\Scripts\activate.bat

@call conda-unpack

@call conda install -y -c conda-forge cudatoolkit=11.7
@call pip3 install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117
@call pip3 install xformers==0.0.16
@call pip3 install -U lama-cleaner
@call lama-cleaner --install-plugins-package

@call lama-cleaner --config-installer --installer-config %0\..\installer_config.json

PAUSE
Gourieff commented 1 year ago

I have no plugin-icon too Neither with GUI:true nor with GUI:false Everything is updated and installed, I did all the steps from this page as well but plugin button doesn't want to appear

This's my win_start.bat (loads with no errors):

@echo off

set PATH=C:\Windows\System32;%PATH%

@call installer\Scripts\activate.bat

@call lama-cleaner --load-installer-config --installer-config %0\..\installer_config.json --enable-realesrgan --realesrgan-model RealESRGAN_x4plus --realesrgan-device cuda --enable-gfpgan --gfpgan-device cuda --enable-restoreformer --restoreformer-device cuda --enable-remove-bg --enable-interactive-seg --enable-gif

PAUSE
Sanster commented 1 year ago

@Gourieff when --installer-config is used, all config is load from installer_config.json, you can add command line arg in installer_config.json

{
    "enable_realesrgan": true,
    "realesrgan_device": "cuda",
    "realesrgan_model": "RealESRGAN_x4plus"
}
Gourieff commented 1 year ago

@Gourieff when --installer-config is used, all config is load from installer_config.json, you can add command line arg in installer_config.json

{
    "enable_realesrgan": true,
    "realesrgan_device": "cuda",
    "realesrgan_model": "RealESRGAN_x4plus"
}

Thanks a lot 👍🏻 It works great! All plugins' files were successfully loaded and the plugin button appeared!

ffdown commented 1 year ago

There is no need to re-download installer, if you are concerned that the current installer environment is messed up, you can unzip the zip package again and replace the contents of win_config.bat with the following:

@echo off

set PATH=C:\Windows\System32;%PATH%

@call installer\Scripts\activate.bat

@call conda-unpack

@call conda install -y -c conda-forge cudatoolkit=11.7
@call pip3 install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117
@call pip3 install xformers==0.0.16
@call pip3 install -U lama-cleaner
@call lama-cleaner --install-plugins-package

@call lama-cleaner --config-installer --installer-config %0\..\installer_config.json

PAUSE

Best option!