diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c1322dc --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = false +insert_final_newline = false \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..f187747 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,69 @@ +# s: set *.js and other as js file for js project +# disable other with linguist-detectable for ps1 +*.ps1 linguist-language=false +*.md linguist-detectable=false +*.py linguist-detectable=true +*.html linguist-detectable=false +*.js linguist-detectable=false +*.css linguist-detectable=false +# s: set *.js and other as js file for js project + +# refer: +# https://huggingface.co/guoyww/animatediff/blob/main/.gitattributes +# https://huggingface.co/datasets/hdparmar/itt_specdata/blob/main/.gitattributes +# https://github.com/Richienb/git-files/blob/master/files/.gitattributes + +*.7z filter=lfs diff=lfs merge=lfs -text +*.arrow filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.ckpt filter=lfs diff=lfs merge=lfs -text +*.ftz filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.h5 filter=lfs diff=lfs merge=lfs -text +*.joblib filter=lfs diff=lfs merge=lfs -text +*.lfs.* filter=lfs diff=lfs merge=lfs -text +*.mlmodel filter=lfs diff=lfs merge=lfs -text +*.model filter=lfs diff=lfs merge=lfs -text +*.msgpack filter=lfs diff=lfs merge=lfs -text +*.npy filter=lfs diff=lfs merge=lfs -text +*.npz filter=lfs diff=lfs merge=lfs -text +*.onnx filter=lfs diff=lfs merge=lfs -text +*.ot filter=lfs diff=lfs merge=lfs -text +*.parquet filter=lfs diff=lfs merge=lfs -text +*.pb filter=lfs diff=lfs merge=lfs -text +*.pickle filter=lfs diff=lfs merge=lfs -text +*.pkl filter=lfs diff=lfs merge=lfs -text +*.pt filter=lfs diff=lfs merge=lfs -text +*.pth filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.safetensors filter=lfs diff=lfs merge=lfs -text +saved_model/**/* filter=lfs diff=lfs merge=lfs -text +*.tar.* filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tflite filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.wasm filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text +*tfevents* filter=lfs diff=lfs merge=lfs -text +# Audio files - uncompressed +*.pcm filter=lfs diff=lfs merge=lfs -text +*.sam filter=lfs diff=lfs merge=lfs -text +*.raw filter=lfs diff=lfs merge=lfs -text +# Audio files - compressed +*.aac filter=lfs diff=lfs merge=lfs -text +*.flac filter=lfs diff=lfs merge=lfs -text +*.mp3 filter=lfs diff=lfs merge=lfs -text +*.ogg filter=lfs diff=lfs merge=lfs -text +*.wav filter=lfs diff=lfs merge=lfs -text +# Image files - uncompressed +*.bmp filter=lfs diff=lfs merge=lfs -text +*.gif filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.tiff filter=lfs diff=lfs merge=lfs -text +# Image files - compressed +*.jpg filter=lfs diff=lfs merge=lfs -text +*.jpeg filter=lfs diff=lfs merge=lfs -text +*.webp filter=lfs diff=lfs merge=lfs -text \ No newline at end of file diff --git a/README.md b/README.md index dd11aef..86a5d76 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,21 @@ - feat(core): node to set it as float type - feat(core): node to set it as number type + +## Nodes +- nodes show in console: +
+ console + +
+ +- nodes show in right mouse menu: + +
+ + right mouse menu +
+ ## Install ```bash @@ -31,19 +46,21 @@ git clone https://github.com/ymc-github/ymc-node-as-x-type ``` -- **deps will be installed automatically** if requirements in requirements.txt not installed when comfyui up +- **deps will be installed automatically** if deps in requirements.txt were not installed when comfyui up ## Usage - you can find it in search box : double click + typing `set it as` - you can find it in right mouse menu : `YMC/LINK` -- you can find it in right mouse menu : `YMC/as_x_type` (as alias) +- ~~you can find it in right mouse menu : `YMC/as_x_type` (as alias)~~ ## Based-on -- pypi package [yors_comfyui_node_setup](https://pypi.org/project/yors_comfyui_node_setup/) +- pypi package [yors_comfyui_node_setup](https://pypi.org/project/yors_comfyui_node_setup/) - setup comfyui custom nodes easily +- ~~pypi package [yors_comfyui_node_as_x_type](https://pypi.org/project/yors_comfyui_node_as_x_type/) - use its nodes~~ +- pypi package [yors_pano_ansi_color](https://pypi.org/project/yors_pano_ansi_color/) - info msg in console with color in your comfyui custom nodes easily +- pypi package [yors_pano_zero_field](https://pypi.org/project/yors_pano_zero_field/) - set nodes input field to be HQ in your comfyui custom nodes easily -- pypi package [yors_comfyui_node_as_x_type](https://pypi.org/project/yors_comfyui_node_as_x_type/) ## Published to Comfy registry diff --git a/__init__.py b/__init__.py index edf96e7..a1ad957 100644 --- a/__init__.py +++ b/__init__.py @@ -1,31 +1,47 @@ -# v1 -# from yors_comfyui_node_setup import entry,node_install_requirements # global -# # install requirements -# node_install_requirements(__file__) +import pathlib +import toml +from yors_comfyui_node_setup import entry +from yors_pano_ansi_color import info_status,info_step,msg_padd,log_msg -# # export comfyui node vars -# __all__,NODE_CLASS_MAPPINGS,NODE_DISPLAY_NAME_MAPPINGS,NODE_MENU_NAMES = entry(__name__,__file__) +def get_version_from_pyproject(file: pathlib.Path, fallback: str = '1.0.0'): + """ + get version from pyproject.toml 's project.version -# v2 -from yors_comfyui_node_setup import node_install_requirements,entry_pre_import,entry_import,get_all_classs_in_sys,register_node_list_local + get_version_from_pyproject(pathlib.Path(__file__).parent / 'pyproject.toml') + """ + try: + pyproject_content = file.read_text() + pyproject = toml.loads(pyproject_content) + version = pyproject.get('project', {}).get('version', '0.0.0') + except FileNotFoundError: + print("pyproject.toml not found, using default version.") + version = fallback + except Exception as e: + print(f"An error occurred while reading pyproject.toml: {e}") + version = fallback + return version -# install requirements -node_install_requirements(__file__) +__all__,NODE_CLASS_MAPPINGS,NODE_DISPLAY_NAME_MAPPINGS,NODE_MENU_NAMES = entry(__name__,__file__,False) -# gen __all__ -__all__ = entry_pre_import(__name__,__file__) +info_step(f"__all__ + WEB_DIRECTORY") +WEB_DIRECTORY = "./web" +__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"] -# import moudle with __all__ -entry_import(__name__,__all__) +# get directory of this file +current_file_path = pathlib.Path(__file__) +name = str(current_file_path.parent) +pyproject_file = current_file_path.parent / 'pyproject.toml' +version= get_version_from_pyproject(pyproject_file) -# get class after importing moudle with __all__ -this_module_all_classes = get_all_classs_in_sys(__name__) -# register node with default category -# NODE_CLASS_MAPPINGS,NODE_DISPLAY_NAME_MAPPINGS,NODE_MENU_NAMES = register_node_list(this_module_all_classes,False) - -# addtional register node with custom category -NODE_CLASS_MAPPINGS,NODE_DISPLAY_NAME_MAPPINGS,NODE_MENU_NAMES = register_node_list_local(this_module_all_classes,True,"YMC/as_x_type") -# print(NODE_CLASS_MAPPINGS,NODE_DISPLAY_NAME_MAPPINGS,NODE_MENU_NAMES) -print("\n".join(NODE_MENU_NAMES)) \ No newline at end of file +log_msg(msg_padd("=",60,"=")) +log_msg(msg_padd(f'welocme to {name}',60,"=")) +log_msg(f'version: {version}') +log_msg(f'node counts:{len(NODE_MENU_NAMES)}') +log_msg(f'node menu names:') +NODE_MENU_NAMES.sort() +for node_name in NODE_MENU_NAMES: + # log_msg(f'node name:{node_name}') + info_status(f'{node_name}',0) +log_msg(msg_padd("=",60,"=")) \ No newline at end of file diff --git a/nodes.py b/nodes.py index 00ce71f..a2cc52d 100644 --- a/nodes.py +++ b/nodes.py @@ -1,21 +1,181 @@ -# 1. define yors comfyui nodes here -# ... +from yors_pano_zero_field import ZeroField,ZERO_ANY -# ucase 1.1: -from yors_comfyui_node_as_x_type import * # import all yors comfyui nodes from it +# class ZeroAnyType(str): +# def __ne__(self, __value: object) -> bool: +# return False +# def __eq__(self, _): +# return True +# ZERO_ANY = ZeroAnyType("*") -# ucase 1.2: -# from yors_comfyui_node_as_x_type import NodeSetItAsImage # import some yors comfyui nodes from it +CURRENT_CATEGORY="YMC/LINK" +CURRENT_FUNCTION="exec" +# feat(core): node to set it as any type +class NodeSetItAsAny: + @classmethod + def INPUT_TYPES(s): + return { + "required": { -# 2. reset yors comfyui nodes category (it will be used set rmb in yors_comfyui_node_setup) -# from yors_comfyui_node_reset_rmb import reset_rmb -# reset_rmb(__name__,"YMC/as_x_type") // danger! + }, + "optional":{ + "a": (ZERO_ANY), + }, + # "hidden": { + # "unique_id": "UNIQUE_ID", + # "extra_pnginfo": "EXTRA_PNGINFO", + # }, + } -# 3. set nodes category alias -# to set the right mouse menu as your likes. + # INPUT_IS_LIST = True + RETURN_TYPES = (ZERO_ANY,) + RETURN_NAMES = ("a",) + + FUNCTION = CURRENT_FUNCTION + CATEGORY = CURRENT_CATEGORY + NODE_NAME = "as any" + NODE_DESC = "set it as any type" + # OUTPUT_NODE = True + # OUTPUT_IS_LIST = (True,) + def exec(self, a=None): + return (a,) + +# feat(core): node to set it as image type +class NodeSetItAsImage: + @classmethod + def INPUT_TYPES(s): + return { + "required": { -import yors_comfyui_node_as_x_type as base -from yors_comfyui_node_setup import get_sys_module,set_node_class_category_alias -this_py_module = get_sys_module(__name__) -set_node_class_category_alias(base,this_py_module,"YMC/as_x_type",True) \ No newline at end of file + }, + "optional":{ + "a": (ZERO_ANY), + }, + # "hidden": { + # "unique_id": "UNIQUE_ID", + # "extra_pnginfo": "EXTRA_PNGINFO", + # }, + } + + # INPUT_IS_LIST = True + RETURN_TYPES = ("IMAGE",) + RETURN_NAMES = ("image",) + + FUNCTION = CURRENT_FUNCTION + CATEGORY = CURRENT_CATEGORY + NODE_NAME = "as image" + NODE_DESC = "set it as image type" + # OUTPUT_NODE = True + # OUTPUT_IS_LIST = (True,) + def exec(self, a=None): + return (a,) + +# feat(core): node to set it as model type +class NodeSetItAsModel: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + + }, + "optional":{ + "a": (ZERO_ANY), + }, + # "hidden": { + # "unique_id": "UNIQUE_ID", + # "extra_pnginfo": "EXTRA_PNGINFO", + # }, + } + + # INPUT_IS_LIST = True + RETURN_TYPES = ("MODEL",) + RETURN_NAMES = ("model",) + + FUNCTION = CURRENT_FUNCTION + CATEGORY = CURRENT_CATEGORY + NODE_NAME = "as model" + NODE_DESC = "set it as model type" + # OUTPUT_NODE = True + # OUTPUT_IS_LIST = (True,) + def exec(self, a=None): + return (a,) + +# feat(core): node to set it as clip type +class NodeSetItAsClip(NodeSetItAsAny): + RETURN_TYPES = ("CLIP",) + RETURN_NAMES = ("clip",) + + FUNCTION = CURRENT_FUNCTION + CATEGORY = CURRENT_CATEGORY + NODE_NAME = "as clip" + NODE_DESC = "set it as clip type" + +# feat(core): node to set it as vae type +class NodeSetItAsVae(NodeSetItAsAny): + RETURN_TYPES = ("VAE",) + RETURN_NAMES = ("vae",) + + FUNCTION = CURRENT_FUNCTION + CATEGORY = CURRENT_CATEGORY + NODE_NAME = "as vae" + NODE_DESC = "set it as vae type" + +# feat(core): node to set it as conditioning type +class NodeSetItAsConditioning(NodeSetItAsAny): + RETURN_TYPES = ("CONDITIONING",) + RETURN_NAMES = ("Conditioning",) + + FUNCTION = CURRENT_FUNCTION + CATEGORY = CURRENT_CATEGORY + NODE_NAME = "as conditioning" + NODE_DESC = "set it as conditioning type" + +# feat(core): node to set it as latent type +class NodeSetItAsLatent(NodeSetItAsAny): + RETURN_TYPES = ("LATENT",) + RETURN_NAMES = ("Latent",) + + FUNCTION = CURRENT_FUNCTION + CATEGORY = CURRENT_CATEGORY + NODE_NAME = "as latent" + NODE_DESC = "set it as latent type" + +# feat(core): node to set it as string type +class NodeSetItAsString(NodeSetItAsAny): + RETURN_TYPES = ("STRING",) + RETURN_NAMES = ("String",) + + FUNCTION = CURRENT_FUNCTION + CATEGORY = CURRENT_CATEGORY + NODE_NAME = "as string" + NODE_DESC = "set it as string type" + +# feat(core): node to set it as int type +class NodeSetItAsInt(NodeSetItAsAny): + RETURN_TYPES = ("INT",) + RETURN_NAMES = ("Int",) + + FUNCTION = CURRENT_FUNCTION + CATEGORY = CURRENT_CATEGORY + NODE_NAME = "as int" + NODE_DESC = "set it as int type" + +# feat(core): node to set it as float type +class NodeSetItAsFloat(NodeSetItAsAny): + RETURN_TYPES = ("FLOAT",) + RETURN_NAMES = ("Float",) + + FUNCTION = CURRENT_FUNCTION + CATEGORY = CURRENT_CATEGORY + NODE_NAME = "as float" + NODE_DESC = "set it as float type" + +# feat(core): node to set it as number type +class NodeSetItAsNumber(NodeSetItAsAny): + RETURN_TYPES = ("NUMBER",) + RETURN_NAMES = ("Number",) + + FUNCTION = CURRENT_FUNCTION + CATEGORY = CURRENT_CATEGORY + NODE_NAME = "as number" + NODE_DESC = "set it as number type" diff --git a/pyproject.toml b/pyproject.toml index ee48cf6..2f08cc9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "ymc-node-as-x-type" description = "some comfyui custom nodes to set it as known type" -version = "0.1.1" +version = "0.1.2" license = { file = "LICENSE" } [project.urls] diff --git a/requirements.txt b/requirements.txt index 666a8eb..848c820 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,4 @@ yors_comfyui_node_setup -yors_comfyui_node_as_x_type \ No newline at end of file +# yors_comfyui_node_as_x_type +yors_pano_zero_field +yors_pano_ansi_color \ No newline at end of file diff --git a/shotscreen/nodes.code.x.png b/shotscreen/nodes.code.x.png new file mode 100644 index 0000000..927e4b6 --- /dev/null +++ b/shotscreen/nodes.code.x.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f8d8be60b87209c0acecac71d4d37ab0f40a59a4e02ea0d7f7fc1e6c19e46530 +size 89382 diff --git a/shotscreen/nodes.console.png b/shotscreen/nodes.console.png new file mode 100644 index 0000000..fa03879 --- /dev/null +++ b/shotscreen/nodes.console.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4406804403ee8ae26608e2e2f587e96e74e73869255519d35bc689a3e2d1b4a3 +size 39039 diff --git a/shotscreen/nodes.right.menu.png b/shotscreen/nodes.right.menu.png new file mode 100644 index 0000000..8bfbb4a --- /dev/null +++ b/shotscreen/nodes.right.menu.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5793e9f9effa992e2366c9075259f7bcc7b0012600518a9403a79ae89c1e7511 +size 39497 diff --git a/shotscreen/nodes.ui.x.png b/shotscreen/nodes.ui.x.png new file mode 100644 index 0000000..cb367aa --- /dev/null +++ b/shotscreen/nodes.ui.x.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dcfbdf88eebf3cc78c3daa6dbae5112e2ef2aab458c4100ec673f3fe287a785c +size 12088