From 64f709741a393ddb4e806be1b06797417d37bac6 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Wed, 11 Dec 2024 21:56:33 +0900 Subject: [PATCH] The Impact Subpack must now be installed separately. --- README.md | 17 +--- install-manual.py | 183 --------------------------------------- install.py | 39 ++------- modules/impact/config.py | 2 +- pyproject.toml | 4 +- requirements.txt | 1 - 6 files changed, 15 insertions(+), 231 deletions(-) delete mode 100644 install-manual.py diff --git a/README.md b/README.md index 30ec162..8c9dd50 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,13 @@ # ComfyUI-Impact-Pack -**Custom nodes pack for ComfyUI** -This custom node helps to conveniently enhance images through Detector, Detailer, Upscaler, Pipe, and more. +**Custom node pack for ComfyUI** +This node pack helps to conveniently enhance images through Detector, Detailer, Upscaler, Pipe, and more. +NOTE: The UltralyticsDetectorProvider node is not part of the ComfyUI-Impact-Pack. To use the UltralyticsDetectorProvider node, please install the ComfyUI-Impact-Subpack separately. ## NOTICE +* V8.0: The `Impact Subpack` is no longer installed automatically. To use `UltralyticsDetectorProvider` nodes, please install the `Impact Subpack` separately. * V7.6: Automatic installation is no longer supported. Please install using ComfyUI-Manager, or manually install requirements.txt and run install.py to complete the installation. * V7.0: Supports Switch based on Execution Model Inversion. * V6.0: Supports FLUX.1 model in Impact KSampler, Detailers, PreviewBridgeLatent @@ -33,9 +35,6 @@ This custom node helps to conveniently enhance images through Detector, Detailer ## Custom Nodes ### [Detector nodes](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/detectors.md) * `SAMLoader` - Loads the SAM model. - * `UltralyticsDetectorProvider` - Loads the Ultralystics model to provide SEGM_DETECTOR, BBOX_DETECTOR. - - Unlike `MMDetDetectorProvider`, for segm models, `BBOX_DETECTOR` is also provided. - - The various models available in UltralyticsDetectorProvider can be downloaded through **ComfyUI-Manager**. * `ONNXDetectorProvider` - Loads the ONNX model to provide BBOX_DETECTOR. * `CLIPSegDetectorProvider` - Wrapper for CLIPSeg to provide BBOX_DETECTOR. * You need to install the ComfyUI-CLIPSeg node extension. @@ -312,12 +311,6 @@ This custom node helps to conveniently enhance images through Detector, Detailer * To use the existing deprecated legacy nodes, you need to enable the MMDet usage configuration. -## Ultralytics models -* When using ultralytics models, save them separately in `models/ultralytics/bbox` and `models/ultralytics/segm` depending on the type of model. Many models can be downloaded by searching for `ultralytics` in the Model Manager of ComfyUI-Manager. -* huggingface.co/Bingsu/[adetailer](https://huggingface.co/Bingsu/adetailer/tree/main) - You can download face, people detection models, and clothing detection models. -* ultralytics/[assets](https://github.com/ultralytics/assets/releases/) - You can download various types of detection models other than faces or people. -* civitai/[adetailer](https://civitai.com/search/models?sortBy=models_v5&query=adetailer) - You can download various types detection models....Many models are associated with NSFW content. - ## How to activate 'MMDet usage' (DEPRECATED) * Upon the initial execution, an `impact-pack.ini` file will be generated in the custom_nodes/ComfyUI-Impact-Pack directory. ``` @@ -359,11 +352,9 @@ mmdet_skip = False * pip install * segment-anything - * ultralytics * scikit-image * piexif * opencv-python - * GitPython * scipy * numpy<2 * dill diff --git a/install-manual.py b/install-manual.py deleted file mode 100644 index 5d15423..0000000 --- a/install-manual.py +++ /dev/null @@ -1,183 +0,0 @@ -import functools -import os -import re -import shutil -import sys -import subprocess -import threading -import locale -import traceback -from typing import Set - - -if sys.argv[0] == 'install.py': - sys.path.append('.') # for portable version - - -impact_path = os.path.join(os.path.dirname(__file__), "modules") -subpack_path = os.path.join(os.path.dirname(__file__), "impact_subpack") -subpack_repo = "https://github.com/ltdrdata/ComfyUI-Impact-Subpack" - - -comfy_path = os.environ.get('COMFYUI_PATH') -if comfy_path is None: - print(f"\n[bold yellow]WARN: The `COMFYUI_PATH` environment variable is not set. Assuming `{os.path.dirname(__file__)}/../../` as the ComfyUI path.[/bold yellow]", file=sys.stderr) - comfy_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) - -model_path = os.environ.get('COMFYUI_MODEL_PATH') -if model_path is None: - try: - import folder_paths - model_path = folder_paths.models_dir - except: - pass - - if model_path is None: - model_path = os.path.abspath(os.path.join(comfy_path, 'models')) - print(f"\n[bold yellow]WARN: The `COMFYUI_MODEL_PATH` environment variable is not set. Assuming `{model_path}` as the ComfyUI path.[/bold yellow]", file=sys.stderr) - - -sys.path.append(impact_path) -sys.path.append(comfy_path) - - -# --- -def handle_stream(stream, is_stdout): - stream.reconfigure(encoding=locale.getpreferredencoding(), errors='replace') - - for msg in stream: - if is_stdout: - print(msg, end="", file=sys.stdout) - else: - print(msg, end="", file=sys.stderr) - - -def process_wrap(cmd_str, cwd=None, handler=None, env=None): - print(f"[Impact Pack] EXECUTE: {cmd_str} in '{cwd}'") - process = subprocess.Popen(cmd_str, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, text=True, bufsize=1) - - if handler is None: - handler = handle_stream - - stdout_thread = threading.Thread(target=handler, args=(process.stdout, True)) - stderr_thread = threading.Thread(target=handler, args=(process.stderr, False)) - - stdout_thread.start() - stderr_thread.start() - - stdout_thread.join() - stderr_thread.join() - - return process.wait() - - -@functools.cache -def get_installed_packages() -> Set[str]: - try: - result = subprocess.check_output([sys.executable, '-m', 'pip', 'list'], universal_newlines=True) - pip_list = set([line.split()[0].lower() for line in result.split('\n') if line.strip()]) - return pip_list - except subprocess.CalledProcessError as e: - raise Exception(f"[ComfyUI-Impact-Pack] Failed to retrieve the information of installed pip packages.") - - -def is_package_installed(name: str) -> bool: - name = name.strip() - pattern = r'([^<>!=]+)([<>!=]=?)' - match = re.search(pattern, name) - - if match: - name = match.group(1) - - result = name.lower() in get_installed_packages() - return result - - -def is_requirements_installed(file_path: str) -> bool: - print(f"Requirements file: {file_path}") - if os.path.exists(file_path): - with open(file_path, "r") as file: - lines = file.readlines() - - for line in lines: - if not is_package_installed(line): - return False - -pip_install = [sys.executable, "-m", "pip", "install", "-U"] - -# --- - - -try: - import platform - import folder_paths - from torchvision.datasets.utils import download_url - import impact.config - - print("### ComfyUI-Impact-Pack: Check dependencies") - def ensure_subpack(): - import git - if os.path.exists(subpack_path): - try: - repo = git.Repo(subpack_path) - repo.remotes.origin.pull() - except: - traceback.print_exc() - if platform.system() == 'Windows': - print(f"[ComfyUI-Impact-Pack] Please turn off ComfyUI and remove '{subpack_path}' and restart ComfyUI.") - else: - shutil.rmtree(subpack_path) - git.Repo.clone_from(subpack_repo, subpack_path) - else: - git.Repo.clone_from(subpack_repo, subpack_path) - - - def install(): - subpack_install_script = os.path.join(subpack_path, "install.py") - - print(f"### ComfyUI-Impact-Pack: Updating subpack") - ensure_subpack() # The installation of the subpack must take place before ensure_pip. cv2 triggers a permission error. - - new_env = os.environ.copy() - new_env["COMFYUI_PATH"] = comfy_path - new_env["COMFYUI_MODEL_PATH"] = model_path - - if os.path.exists(subpack_install_script): - if not is_requirements_installed(os.path.join(subpack_path, 'requirements.txt')): - process_wrap(pip_install + ['-r', 'requirements.txt'], cwd=subpack_path) - - process_wrap([sys.executable, 'install.py'], cwd=subpack_path, env=new_env) - else: - print(f"### ComfyUI-Impact-Pack: (Install Failed) Subpack\nFile not found: `{subpack_install_script}`") - - # Download model - print("### ComfyUI-Impact-Pack: Check basic models") - sam_path = os.path.join(model_path, "sams") - onnx_path = os.path.join(model_path, "onnx") - - if not os.path.exists(os.path.join(os.path.dirname(__file__), '..', 'skip_download_model')): - if not impact.config.get_config()['mmdet_skip']: - bbox_path = os.path.join(model_path, "mmdets", "bbox") - if not os.path.exists(bbox_path): - os.makedirs(bbox_path) - - if not os.path.exists(os.path.join(bbox_path, "mmdet_anime-face_yolov3.pth")): - download_url("https://huggingface.co/dustysys/ddetailer/resolve/main/mmdet/bbox/mmdet_anime-face_yolov3.pth", bbox_path) - - if not os.path.exists(os.path.join(bbox_path, "mmdet_anime-face_yolov3.py")): - download_url("https://raw.githubusercontent.com/Bing-su/dddetailer/master/config/mmdet_anime-face_yolov3.py", bbox_path) - - if not os.path.exists(os.path.join(sam_path, "sam_vit_b_01ec64.pth")): - download_url("https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth", sam_path) - - if not os.path.exists(onnx_path): - print(f"### ComfyUI-Impact-Pack: onnx model directory created ({onnx_path})") - os.mkdir(onnx_path) - - impact.config.write_config() - - install() - -except Exception as e: - print("[ERROR] ComfyUI-Impact-Pack: Dependency installation has failed. Please install manually.") - traceback.print_exc() diff --git a/install.py b/install.py index 5803d79..3fac621 100644 --- a/install.py +++ b/install.py @@ -12,13 +12,11 @@ if sys.argv[0] == 'install.py': impact_path = os.path.join(os.path.dirname(__file__), "modules") -subpack_path = os.path.join(os.path.dirname(__file__), "impact_subpack") -subpack_repo = "https://github.com/ltdrdata/ComfyUI-Impact-Subpack" comfy_path = os.environ.get('COMFYUI_PATH') if comfy_path is None: - print(f"\n[bold yellow]WARN: The `COMFYUI_PATH` environment variable is not set. Assuming `{os.path.dirname(__file__)}/../../` as the ComfyUI path.[/bold yellow]", file=sys.stderr) + print(f"\nWARN: The `COMFYUI_PATH` environment variable is not set. Assuming `{os.path.dirname(__file__)}/../../` as the ComfyUI path.", file=sys.stderr) comfy_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) model_path = os.environ.get('COMFYUI_MODEL_PATH') @@ -31,7 +29,7 @@ if model_path is None: if model_path is None: model_path = os.path.abspath(os.path.join(comfy_path, 'models')) - print(f"\n[bold yellow]WARN: The `COMFYUI_MODEL_PATH` environment variable is not set. Assuming `{model_path}` as the ComfyUI path.[/bold yellow]", file=sys.stderr) + print(f"\nWARN: The `COMFYUI_MODEL_PATH` environment variable is not set. Assuming `{model_path}` as the ComfyUI path.", file=sys.stderr) sys.path.append(impact_path) @@ -76,38 +74,11 @@ try: import impact.config print("### ComfyUI-Impact-Pack: Check dependencies") - def ensure_subpack(): - import git - if os.path.exists(subpack_path): - try: - repo = git.Repo(subpack_path) - repo.remotes.origin.pull() - except: - traceback.print_exc() - if platform.system() == 'Windows': - print(f"[ComfyUI-Impact-Pack] Please turn off ComfyUI and remove '{subpack_path}' and restart ComfyUI.") - else: - shutil.rmtree(subpack_path) - git.Repo.clone_from(subpack_repo, subpack_path) - else: - git.Repo.clone_from(subpack_repo, subpack_path) - - def install(): - subpack_install_script = os.path.join(subpack_path, "install.py") - - print(f"### ComfyUI-Impact-Pack: Updating subpack") - ensure_subpack() # The installation of the subpack must take place before ensure_pip. cv2 triggers a permission error. - new_env = os.environ.copy() new_env["COMFYUI_PATH"] = comfy_path new_env["COMFYUI_MODEL_PATH"] = model_path - if os.path.exists(subpack_install_script): - process_wrap([sys.executable, 'install.py'], cwd=subpack_path, env=new_env) - else: - print(f"### ComfyUI-Impact-Pack: (Install Failed) Subpack\nFile not found: `{subpack_install_script}`") - # Download model print("### ComfyUI-Impact-Pack: Check basic models") sam_path = os.path.join(model_path, "sams") @@ -137,6 +108,12 @@ try: impact.config.write_config() + # Remove legacy subpack + subpack_path = os.path.join(os.path.dirname(__file__), 'impact_subpack') + if os.path.exists(subpack_path): + shutil.rmtree(subpack_path) + print(f"Legacy subpack is detected. '{subpack_path}' is removed.") + install() except Exception as e: diff --git a/modules/impact/config.py b/modules/impact/config.py index abcb40f..c529cbc 100644 --- a/modules/impact/config.py +++ b/modules/impact/config.py @@ -1,7 +1,7 @@ import configparser import os -version_code = [7, 14, 3] +version_code = [8, 0] version = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '') dependency_version = 24 diff --git a/pyproject.toml b/pyproject.toml index 35d13c0..f07b144 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-impact-pack" -description = "This extension offers various detector nodes and detailer nodes that allow you to configure a workflow that automatically enhances facial details. And provide iterative upscaler." -version = "7.14.3" +description = "This node pack offers various detector nodes and detailer nodes that allow you to configure a workflow that automatically enhances facial details. And provide iterative upscaler." +version = "8.0" license = { file = "LICENSE.txt" } dependencies = ["segment-anything", "scikit-image", "piexif", "transformers", "opencv-python-headless", "GitPython", "scipy>=1.11.4"] diff --git a/requirements.txt b/requirements.txt index 0066b6d..6e21ffc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,6 @@ scikit-image piexif transformers opencv-python-headless -GitPython scipy>=1.11.4 numpy<2 dill