Uminosachi / sd-webui-inpaint-anything

Inpaint Anything extension performs stable diffusion inpainting on a browser UI using masks from Segment Anything.
Apache License 2.0
1.08k stars 99 forks source link

Give ModuleNotFoundError for few packages #153

Open YukiRed opened 1 month ago

YukiRed commented 1 month ago

Package like the following is not install

Turns out it is because launch is not available and unable to pip install launch. Have to change to using subprocess

import subprocess

required_packages = {
    "accelerate": "accelerate",
    "diffusers": "diffusers",
    "huggingface_hub": "huggingface-hub",
    "numpy": "numpy",
    "cv2": "opencv-python",
    "PIL": "Pillow",
    "segment_anything": "segment-anything",
    "transformers": "transformers",
    "ultralytics": "ultralytics",
    "tqdm": "tqdm",
    "packaging": "packaging",
    "loguru": "loguru",
    "rich": "rich",
    "pydantic": "pydantic",
    "timm": "timm",
}

for package in required_packages:
    try:
        __import__(package)
        print(f"{package} is already installed.")
    except ImportError:
        try:
            subprocess.run(["pip", "install", required_packages[package]], check=True)
            print(f"Successfully installed {required_packages[package]}.")
        except subprocess.CalledProcessError:
            print(f"Can't install {required_packages[package]}. Please follow the readme to install manually.")
Uminosachi commented 1 month ago

Although I couldn't reproduce the issue, I have modified the install.py file to allow installation even when the launch package is not found. Please update and try again.