This commit is contained in:
madtunebk
2024-03-13 20:50:09 +02:00
committed by GitHub
parent 02e6eeae7d
commit 86fbbc7cbe
5 changed files with 70 additions and 61 deletions
+7 -45
View File
@@ -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",
]
+17
View File
@@ -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"
}
+46
View File
@@ -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
}
View File
-16
View File
@@ -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',
],
)