diff --git a/README.MD b/README.MD index c3ab7df..4b5d767 100644 --- a/README.MD +++ b/README.MD @@ -80,6 +80,7 @@ When this error has occurred, please check the network environment. ## Update **If the dependency package error after updating, please reinstall the relevant dependency packages.
+* Commit [SD3NegativeConditioning](#SD3NegativeConditioning) node, Encapsulate the four nodes of Negative Condition in SD3 into a separate node. * [ImageRemoveAlpha](#ImageRemoveAlpha) node add optional mask input. * Commit [HLFrequencyDetailRestore](#HLFrequencyDetailRestore) node, Using low-frequency filtering and high-frequency preserving to restore image details, the fusion is better. * Commit [AddGrain](#AddGrain) and [MaskGrain](#MaskGrain) nodes, Add noise to a picture or mask. @@ -1224,6 +1225,15 @@ layer_iamge: Find the layer output. all_layers: Batch images containing all layers. +### SD3NegativeConditioning +![image](image/sd3_negative_conditioning_node_note.jpg) +Encapsulate the four nodes of Negative Condition in SD3 into a separate node. + +Node Options: +![image](image/sd3_negative_conditioning_node.jpg) +* zero_out_start: Set the ConditioningSetTimestepRange start value for Negative ConditioningZeroOut, which is the same as the ConditioningSetTimestepRange end value for Negative. + + # LayerMask ![image](image/layermask_nodes.jpg) diff --git a/README_CN.MD b/README_CN.MD index fbf875f..352de9a 100644 --- a/README_CN.MD +++ b/README_CN.MD @@ -80,6 +80,7 @@ git clone https://github.com/chflame163/ComfyUI_LayerStyle.git ## 更新说明 **如果本插件更新后出现依赖包错误,请重新安装相关依赖包。 +* 添加 [SD3NegativeConditioning](#SD3NegativeConditioning) 节点, 把SD3的Negative Conditioning 的4个节点封装为一个单独节点。 * [ImageRemoveAlpha](#ImageRemoveAlpha) 节点增加mask可选输入。 * 添加 [HLFrequencyDetailRestore](#HLFrequencyDetailRestore)节点, 使用低频滤波加保留高频来恢复图像细节,图像融合性更好。 * 添加 [AddGrain](#AddGrain) 和 [MaskGrain](#MaskGrain) 节点, 为图片或遮罩添加噪声。 @@ -1207,6 +1208,14 @@ flat_image: psd预览图。 layer_iamge: 查找的图层输出。 all_layers: 包含全部图层的批量图片。 +### SD3NegativeConditioning +![image](image/sd3_negative_conditioning_node_note.jpg) +把SD3的Negative Conditioning 的4个节点封装为一个单独节点。 + +节点选项说明: +![image](image/sd3_negative_conditioning_node.jpg) +* zero_out_start: 设置Negative ConditioningZeroOut的ConditioningSetTimestepRange start值, 此数值与Negative的ConditioningSetTimestepRange end值相同。 + # LayerMask ![image](image/layermask_nodes.jpg) diff --git a/image/sd3_negative_conditioning_example.jpg b/image/sd3_negative_conditioning_example.jpg new file mode 100644 index 0000000..299718b Binary files /dev/null and b/image/sd3_negative_conditioning_example.jpg differ diff --git a/image/sd3_negative_conditioning_node.jpg b/image/sd3_negative_conditioning_node.jpg new file mode 100644 index 0000000..e19548e Binary files /dev/null and b/image/sd3_negative_conditioning_node.jpg differ diff --git a/image/sd3_negative_conditioning_node_note.jpg b/image/sd3_negative_conditioning_node_note.jpg new file mode 100644 index 0000000..913d07a Binary files /dev/null and b/image/sd3_negative_conditioning_node_note.jpg differ diff --git a/py/sd3_negative_conditioning.py b/py/sd3_negative_conditioning.py new file mode 100644 index 0000000..499bb37 --- /dev/null +++ b/py/sd3_negative_conditioning.py @@ -0,0 +1,48 @@ +import torch +import node_helpers + +NODE_NAME = 'SD3NegativeConditioning' + +class SD3NegativeConditioning: + + @classmethod + def INPUT_TYPES(self): + return {"required": {"conditioning": ("CONDITIONING", ), + "zero_out_start": ("FLOAT", {"default": 0.1, "min": 0.0, "max": 1.0, "step": 0.001}), + }} + + RETURN_TYPES = ("CONDITIONING",) + FUNCTION = 'sd3_negative_conditioning' + CATEGORY = '😺dzNodes/LayerUtility/SystemIO' + + def sd3_negative_conditioning(self, conditioning, zero_out_start): + def zero_out(conditioning): + c = [] + for t in conditioning: + d = t[1].copy() + if "pooled_output" in d: + d["pooled_output"] = torch.zeros_like(d["pooled_output"]) + n = [torch.zeros_like(t[0]), d] + c.append(n) + return c + + def set_range(conditioning, start, end): + c = node_helpers.conditioning_set_values(conditioning, {"start_percent": start, + "end_percent": end}) + return c + + zero_out_c = zero_out(conditioning) + c_1 = set_range(zero_out_c, zero_out_start, 1.0) + c_2 = set_range(conditioning, 0.0, zero_out_start) + return (c_1 + c_2,) + + + + +NODE_CLASS_MAPPINGS = { + "LayerUtility: SD3NegativeConditioning": SD3NegativeConditioning +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "LayerUtility: SD3NegativeConditioning": "LayerUtility: SD3 Negative Conditioning" +} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index ed6c61c..8f42dcc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui_layerstyle" description = "A set of nodes for ComfyUI it generate image like Adobe Photoshop's Layer Style. the Drop Shadow is first completed node, and follow-up work is in progress." -version = "1.0.5" +version = "1.0.6" license = "MIT" dependencies = ["numpy", "pillow", "torch", "matplotlib", "Scipy", "scikit_image", "opencv-contrib-python", "pymatting", "segment_anything", "timm", "addict", "yapf", "colour-science", "wget", "mediapipe", "loguru", "typer_config", "fastapi", "rich", "google-generativeai", "diffusers", "omegaconf", "tqdm", "transformers", "kornia", "image-reward", "ultralytics", "blend_modes", "blind-watermark", "qrcode", "pyzbar", "psd-tools"] diff --git a/workflow/sd3_negative_conditioning.json b/workflow/sd3_negative_conditioning.json new file mode 100644 index 0000000..7e2b334 --- /dev/null +++ b/workflow/sd3_negative_conditioning.json @@ -0,0 +1,434 @@ +{ + "last_node_id": 282, + "last_link_id": 619, + "nodes": [ + { + "id": 6, + "type": "CLIPTextEncode", + "pos": [ + 1210, + 690 + ], + "size": { + "0": 389.06927490234375, + "1": 207.84902954101562 + }, + "flags": {}, + "order": 2, + "mode": 0, + "inputs": [ + { + "name": "clip", + "type": "CLIP", + "link": 601 + } + ], + "outputs": [ + { + "name": "CONDITIONING", + "type": "CONDITIONING", + "links": [ + 605 + ], + "shape": 3, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "CLIPTextEncode" + }, + "widgets_values": [ + "a female character with long, flowing hair that appears to be made of ethereal, swirling patterns resembling the Northern Lights or Aurora Borealis. The background is dominated by deep blues and purples, creating a mysterious and dramatic atmosphere. The character's face is serene, with pale skin and striking features. She wears a dark-colored outfit with subtle patterns. The overall style of the artwork is reminiscent of fantasy or supernatural genres" + ], + "color": "#232", + "bgcolor": "#353" + }, + { + "id": 135, + "type": "EmptySD3LatentImage", + "pos": [ + 1650, + 940 + ], + "size": { + "0": 315, + "1": 106 + }, + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "LATENT", + "type": "LATENT", + "links": [ + 607 + ], + "shape": 3, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "EmptySD3LatentImage" + }, + "widgets_values": [ + 1024, + 1024, + 1 + ] + }, + { + "id": 275, + "type": "KSampler", + "pos": [ + 2060, + 590 + ], + "size": { + "0": 315, + "1": 446 + }, + "flags": {}, + "order": 5, + "mode": 0, + "inputs": [ + { + "name": "model", + "type": "MODEL", + "link": 604 + }, + { + "name": "positive", + "type": "CONDITIONING", + "link": 605 + }, + { + "name": "negative", + "type": "CONDITIONING", + "link": 612 + }, + { + "name": "latent_image", + "type": "LATENT", + "link": 607 + } + ], + "outputs": [ + { + "name": "LATENT", + "type": "LATENT", + "links": [ + 613 + ], + "shape": 3, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "KSampler" + }, + "widgets_values": [ + 945512652412924, + "fixed", + 28, + 4.5, + "dpmpp_2m", + "sgm_uniform", + 1 + ] + }, + { + "id": 279, + "type": "VAEDecode", + "pos": [ + 2420, + 623 + ], + "size": { + "0": 210, + "1": 46 + }, + "flags": {}, + "order": 6, + "mode": 0, + "inputs": [ + { + "name": "samples", + "type": "LATENT", + "link": 613 + }, + { + "name": "vae", + "type": "VAE", + "link": 614 + } + ], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 615 + ], + "shape": 3, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "VAEDecode" + } + }, + { + "id": 280, + "type": "PreviewImage", + "pos": [ + 2699, + 576 + ], + "size": { + "0": 440.6585693359375, + "1": 455.54217529296875 + }, + "flags": {}, + "order": 7, + "mode": 0, + "inputs": [ + { + "name": "images", + "type": "IMAGE", + "link": 615 + } + ], + "properties": { + "Node name for S&R": "PreviewImage" + } + }, + { + "id": 273, + "type": "CheckpointLoaderSimple", + "pos": [ + 653, + 600 + ], + "size": { + "0": 485.783447265625, + "1": 103.3435287475586 + }, + "flags": {}, + "order": 1, + "mode": 0, + "outputs": [ + { + "name": "MODEL", + "type": "MODEL", + "links": [ + 604 + ], + "shape": 3, + "slot_index": 0 + }, + { + "name": "CLIP", + "type": "CLIP", + "links": [ + 601, + 602 + ], + "shape": 3, + "slot_index": 1 + }, + { + "name": "VAE", + "type": "VAE", + "links": [ + 614 + ], + "shape": 3, + "slot_index": 2 + } + ], + "properties": { + "Node name for S&R": "CheckpointLoaderSimple" + }, + "widgets_values": [ + "SD3\\2b_1024\\sd3_medium_incl_clips_t5xxlfp8.safetensors" + ] + }, + { + "id": 71, + "type": "CLIPTextEncode", + "pos": [ + 1215, + 968 + ], + "size": { + "0": 380.4615783691406, + "1": 102.07693481445312 + }, + "flags": {}, + "order": 3, + "mode": 0, + "inputs": [ + { + "name": "clip", + "type": "CLIP", + "link": 602 + } + ], + "outputs": [ + { + "name": "CONDITIONING", + "type": "CONDITIONING", + "links": [ + 611 + ], + "shape": 3, + "slot_index": 0 + } + ], + "title": "CLIP Text Encode (Negative Prompt)", + "properties": { + "Node name for S&R": "CLIPTextEncode" + }, + "widgets_values": [ + "bad quality, poor quality, doll, disfigured, jpg, toy, bad anatomy, missing limbs, missing fingers, 3d, cgi" + ], + "color": "#322", + "bgcolor": "#533" + }, + { + "id": 278, + "type": "LayerUtility: SD3NegativeConditioning", + "pos": [ + 1647, + 778 + ], + "size": { + "0": 327.6000061035156, + "1": 58 + }, + "flags": {}, + "order": 4, + "mode": 0, + "inputs": [ + { + "name": "conditioning", + "type": "CONDITIONING", + "link": 611 + } + ], + "outputs": [ + { + "name": "CONDITIONING", + "type": "CONDITIONING", + "links": [ + 612 + ], + "shape": 3, + "slot_index": 0 + } + ], + "properties": { + "Node name for S&R": "LayerUtility: SD3NegativeConditioning" + }, + "widgets_values": [ + 0.1 + ] + } + ], + "links": [ + [ + 601, + 273, + 1, + 6, + 0, + "CLIP" + ], + [ + 602, + 273, + 1, + 71, + 0, + "CLIP" + ], + [ + 604, + 273, + 0, + 275, + 0, + "MODEL" + ], + [ + 605, + 6, + 0, + 275, + 1, + "CONDITIONING" + ], + [ + 607, + 135, + 0, + 275, + 3, + "LATENT" + ], + [ + 611, + 71, + 0, + 278, + 0, + "CONDITIONING" + ], + [ + 612, + 278, + 0, + 275, + 2, + "CONDITIONING" + ], + [ + 613, + 275, + 0, + 279, + 0, + "LATENT" + ], + [ + 614, + 273, + 2, + 279, + 1, + "VAE" + ], + [ + 615, + 279, + 0, + 280, + 0, + "IMAGE" + ] + ], + "groups": [], + "config": {}, + "extra": { + "ds": { + "scale": 0.6830134553650706, + "offset": [ + -69.02360401680795, + -15.503216960225018 + ] + } + }, + "version": 0.4 +} \ No newline at end of file