Skip to content

Commit

Permalink
commit SD3NegativeConditioning node
Browse files Browse the repository at this point in the history
  • Loading branch information
chflame163 committed Jun 13, 2024
1 parent 32dee1e commit e06df57
Show file tree
Hide file tree
Showing 8 changed files with 502 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ When this error has occurred, please check the network environment.
## Update
<font size="4">**If the dependency package error after updating, please reinstall the relevant dependency packages. </font><br />

* 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.
Expand Down Expand Up @@ -1224,6 +1225,15 @@ layer_iamge: Find the layer output.
all_layers: Batch images containing all layers.


### <a id="table1">SD3NegativeConditioning</a>
![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.


# <a id="table1">LayerMask</a>
![image](image/layermask_nodes.jpg)

Expand Down
9 changes: 9 additions & 0 deletions README_CN.MD
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ git clone https://github.com/chflame163/ComfyUI_LayerStyle.git
## 更新说明
<font size="4">**如果本插件更新后出现依赖包错误,请重新安装相关依赖包。

* 添加 [SD3NegativeConditioning](#SD3NegativeConditioning) 节点, 把SD3的Negative Conditioning 的4个节点封装为一个单独节点。
* [ImageRemoveAlpha](#ImageRemoveAlpha) 节点增加mask可选输入。
* 添加 [HLFrequencyDetailRestore](#HLFrequencyDetailRestore)节点, 使用低频滤波加保留高频来恢复图像细节,图像融合性更好。
* 添加 [AddGrain](#AddGrain)[MaskGrain](#MaskGrain) 节点, 为图片或遮罩添加噪声。
Expand Down Expand Up @@ -1207,6 +1208,14 @@ flat_image: psd预览图。
layer_iamge: 查找的图层输出。
all_layers: 包含全部图层的批量图片。

### <a id="table1">SD3NegativeConditioning</a>
![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值相同。


# <a id="table1">LayerMask</a>
![image](image/layermask_nodes.jpg)
Expand Down
Binary file added image/sd3_negative_conditioning_example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/sd3_negative_conditioning_node.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/sd3_negative_conditioning_node_note.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions py/sd3_negative_conditioning.py
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"]

Expand Down
Loading

0 comments on commit e06df57

Please sign in to comment.