From 86fbbc7cbe706958f4423dea92600a1659b772eb Mon Sep 17 00:00:00 2001 From: madtunebk <128463309+madtunebk@users.noreply.github.com> Date: Wed, 13 Mar 2024 20:50:09 +0200 Subject: [PATCH] update --- __init__.py | 52 +++++--------------------------------- comfyui_custom_node.json | 17 +++++++++++++ nodes/controlnetaux.py | 46 +++++++++++++++++++++++++++++++++ funcs.py => nodes/funcs.py | 0 setup.py | 16 ------------ 5 files changed, 70 insertions(+), 61 deletions(-) create mode 100644 comfyui_custom_node.json create mode 100644 nodes/controlnetaux.py rename funcs.py => nodes/funcs.py (100%) delete mode 100644 setup.py diff --git a/__init__.py b/__init__.py index 2b6c0d0..61cc023 100644 --- a/__init__.py +++ b/__init__.py @@ -5,50 +5,12 @@ @description: This ComfyUI custom node, named ControlNet Auxiliar, is designed to provide auxiliary functionalities for image processing tasks. It is particularly useful for various image manipulation and enhancement operations. The node is integrated with functionalities for converting images between different formats and applying various image processing techniques. """ -from controlnet_aux.processor import Processor -import traceback +from .nodes import controlnet_auxiar -from .funcs import pil2tensor, tensor2pil +version_code = [0, 67] +version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '') +print(f"### Loading: ControlnetAux ({version_str})") - -class controlnet_auxiar: - def __init__(self): - pass - - @classmethod - def INPUT_TYPES(cls): # Changed s to cls - modules = [ "scribble_hed", "softedge_hed", "scribble_hedsafe", "softedge_hedsafe", "depth_midas", "openpose", "openpose_face", "openpose_faceonly", "openpose_full", "openpose_hand", "scribble_pidinet", "softedge_pidinet", "scribble_pidsafe", "softedge_pidsafe", "normal_bae", "lineart_coarse", "lineart_realistic", "lineart_anime", "depth_zoe", "depth_leres", "depth_leres++", "shuffle", "mediapipe_face", "canny"] - return { - "required": { - "image": ("IMAGE",), - "mode": ([modules, ]) - }, - "optional": { - "low_threshold": ("INT", {"default": 50, "min": 1, "max": 200, "step": 1}), - "high_threshold": ("INT", {"default": 100, "min": 1, "max": 200, "step": 1}), - "image_resolution": ("INT", {"default": 512, "min": 512, "max": 1024, "step": 1}), - } - } - RETURN_TYPES = ("IMAGE",) - FUNCTION = "process_image" - CATEGORY = "image" - - def process_image(self, image, mode, low_threshold, high_threshold, image_resolution): - convert_image = tensor2pil(image) - try: - if mode == "canny": - params = {"low_threshold": low_threshold, "high_threshold" : high_threshold, "image_resolution": image_resolution} - else: - params = {} - - processor = Processor(mode, params=params) - processed_image = processor(convert_image, to_pil=True) - return (pil2tensor(processed_image),) - except: - print(type(convert_image)) - traceback.print_exc() - raise ValueError("Unsupported image format") - -NODE_CLASS_MAPPINGS = { - "ControlNet Auxiliar": controlnet_auxiar -} +node_list = [ + "controlnetaux", +] \ No newline at end of file diff --git a/comfyui_custom_node.json b/comfyui_custom_node.json new file mode 100644 index 0000000..6141ee5 --- /dev/null +++ b/comfyui_custom_node.json @@ -0,0 +1,17 @@ +{ + "name": "ControlNet Auxiliar", + "description": "Provides auxiliary functionalities for image processing tasks.", + "author": "Cornea Valentin", + "version": "1.0.0", + "node_class": "controlnet_aux.processor", + "inputs": { + "image": "IMAGE", + "mode": [ "scribble_hed", "softedge_hed", "scribble_hedsafe", "softedge_hedsafe", "depth_midas", "openpose", "openpose_face", "openpose_faceonly", "openpose_full", "openpose_hand", "scribble_pidinet", "softedge_pidinet", "scribble_pidsafe", "softedge_pidsafe", "normal_bae", "lineart_coarse", "lineart_realistic", "lineart_anime", "depth_zoe", "depth_leres", "depth_leres++", "shuffle", "mediapipe_face", "canny"] + }, + "outputs": { + "processed_image": "IMAGE" + }, + "category": "Image Processing", + "tags": ["image", "processing", "auxiliary"], + "icon": "workflows/example.png" + } \ No newline at end of file diff --git a/nodes/controlnetaux.py b/nodes/controlnetaux.py new file mode 100644 index 0000000..a8c0036 --- /dev/null +++ b/nodes/controlnetaux.py @@ -0,0 +1,46 @@ +from controlnet_aux.processor import Processor +import traceback + +from .nodes.funcs import pil2tensor, tensor2pil + +class controlnet_auxiar: + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(cls): # Changed s to cls + modules = [ "scribble_hed", "softedge_hed", "scribble_hedsafe", "softedge_hedsafe", "depth_midas", "openpose", "openpose_face", "openpose_faceonly", "openpose_full", "openpose_hand", "scribble_pidinet", "softedge_pidinet", "scribble_pidsafe", "softedge_pidsafe", "normal_bae", "lineart_coarse", "lineart_realistic", "lineart_anime", "depth_zoe", "depth_leres", "depth_leres++", "shuffle", "mediapipe_face", "canny"] + return { + "required": { + "image": ("IMAGE",), + "mode": ([modules, ]) + }, + "optional": { + "low_threshold": ("INT", {"default": 50, "min": 1, "max": 200, "step": 1}), + "high_threshold": ("INT", {"default": 100, "min": 1, "max": 200, "step": 1}), + "image_resolution": ("INT", {"default": 512, "min": 512, "max": 1024, "step": 1}), + } + } + RETURN_TYPES = ("IMAGE",) + FUNCTION = "process_image" + CATEGORY = "image" + + def process_image(self, image, mode, low_threshold, high_threshold, image_resolution): + convert_image = tensor2pil(image) + try: + if mode == "canny": + params = {"low_threshold": low_threshold, "high_threshold" : high_threshold, "image_resolution": image_resolution} + else: + params = {} + + processor = Processor(mode, params=params) + processed_image = processor(convert_image, to_pil=True) + return (pil2tensor(processed_image),) + except: + print(type(convert_image)) + traceback.print_exc() + raise ValueError("Unsupported image format") + +NODE_CLASS_MAPPINGS = { + "ControlNet Auxiliar": controlnet_auxiar +} \ No newline at end of file diff --git a/funcs.py b/nodes/funcs.py similarity index 100% rename from funcs.py rename to nodes/funcs.py diff --git a/setup.py b/setup.py deleted file mode 100644 index 9047d3c..0000000 --- a/setup.py +++ /dev/null @@ -1,16 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name='ComfyUI-ControlnetAux', - version='1.0.0', - description='ComfyUI Custom Node: ControlNet Auxiliar', - long_description='This ComfyUI custom node, named ControlNet Auxiliar, is designed to provide auxiliary functionalities for image processing tasks. It is particularly useful for various image manipulation and enhancement operations. The node is integrated with functionalities for converting images between different formats and applying various image processing techniques.', - author='Cornea Valentin', - author_email='valicornea84@gmail.com', - url='https://github.com/madtunebk/ComfyUI-ControlnetAux', - packages=find_packages(), - install_requires=[ - 'timm==0.6.12', - 'controlnet-aux==0.0.7', - ], -)