KutsuyaYuki / ABG_extension

228 stars 23 forks source link

Installing requirements for Anime Background Remover on every launch #6

Closed Golgovskiy closed 1 year ago

Golgovskiy commented 1 year ago
Installing requirements for Anime Background Remover
Installing requirements for Anime Background Remover
Installing requirements for Anime Background Remover

Happens every single launch. Is this intended behaviour? It does work in UI.

KutsuyaYuki commented 1 year ago

This is intended behavior. This is done because WebUI checks the script's requirements every boot

Golgovskiy commented 1 year ago

You mean, it's just writing it regardless of the result of the check, or does it reinstall requirements every time?

KutsuyaYuki commented 1 year ago

The code is checking if the dependency is installed, and if not, it will install the appropriate version. It will not reinstall the dependency if it is already present.

Golgovskiy commented 1 year ago

So... Does it write the message every check or only on install? Or is my system fails check every time for some reason? It works thou.

KutsuyaYuki commented 1 year ago

It just writes the message, even if it is already installed. It won't reinstall it.

Golgovskiy commented 1 year ago

I see. Good. Thank you. Any chance to make it not write the message if it doesn't actually installs anything?

I read the script, and I can't understand. It writes message in "if" branch, how come it writes it if it found it installed? There is 5 lines, but I only writes three. That is too say, it didn't find them installed, but pip didn't install because they actually were?

KutsuyaYuki commented 1 year ago

Can you try the new version? I am currently unable to test it myself since I'm at work.

Golgovskiy commented 1 year ago
Installing requirements for Web UI
Installing None
Installing onnxruntime-gpu...
Installing None
Installing opencv-python...
Installing None
Installing Pillow...
Murlors commented 1 year ago
Installing requirements for Web UI
Installing None
Installing onnxruntime-gpu...
Installing None
Installing opencv-python...
Installing None
Installing Pillow...

I think this may be due to the following reasons: The is_installed function in launch.py uses the importlib.util.find_spec method, which is used to find the specification of the module, but you use the package name as an argument in install.py, which should be the module name and not the package name. So I think the following changes can be made.

if not launch.is_installed("onnx"):
    launch.run_pip("install onnx", desc="onnx")
    # print("Installing onnx...")

if not launch.is_installed("onnxruntime"):  # used to be onnxruntime-gpu
    launch.run_pip("install onnxruntime-gpu", desc="onnxruntime-gpu")
    # print("Installing onnxruntime-gpu...")

if not launch.is_installed("cv2"):  # used to be opencv-python
    launch.run_pip("install opencv-python", desc="opencv-python")
    # print("Installing opencv-python...")

if not launch.is_installed("numpy"):
    launch.run_pip("install numpy", desc="numpy")
    # print("Installing numpy...")

if not launch.is_installed("PIL"):  # used to be Pillow
    launch.run_pip("install Pillow", desc="Pillow")
    # print("Installing Pillow...")

Also, I commented out print and added the argument desc because print is already done in the run_pip method.

I tested it on my computer and it worked as expected. Would you like me to submit a pull request to address this issue?