Refactor initialization in __init__.py to include ColorPicker and update NODE_CLASS_MAPPINGS. Enhance README files with parameter settings and examples for text processing features. Update documentation to improve clarity and usability.

This commit is contained in:
fujammy
2024-12-25 11:58:40 +08:00
parent 2266642088
commit 8a19b6c970
10 changed files with 73 additions and 6 deletions
+12
View File
@@ -86,6 +86,18 @@ Use Cases:
- Preparing text for text-to-image generation
- Standardizing text input format
Parameter Settings:
![Parameter Settings](docment/images/rm_line_and_space_cn01.png)
Example with keep_single_empty_line=True:
![Keep Single Empty Line](docment/images/rm_line_and_space_cn02.png)
Example with preserve_indentation=True:
![Preserve Indentation](docment/images/rm_line_and_space_cn03.png)
Example with trim_trailing_spaces=True:
![Trim Trailing Spaces](docment/images/rm_line_and_space_cn04.png)
## 📝 License
MIT License
+12
View File
@@ -86,6 +86,18 @@
- 准备文生图的输入文本
- 标准化文本输入格式
参数设置:
![参数设置](docment/images/rm_line_and_space_cn01.png)
保留单个空行的示例:
![保留单个空行](docment/images/rm_line_and_space_cn02.png)
保留缩进的示例:
![保留缩进](docment/images/rm_line_and_space_cn03.png)
移除尾随空格的示例:
![移除尾随空格](docment/images/rm_line_and_space_cn04.png)
## 📝 许可证
MIT License
+5 -6
View File
@@ -4,21 +4,20 @@ setup()
try:
from .image_resolution_adjuster import ImageResolutionAdjuster
# 暂时注释掉未实现的节点
# from .dynamic_image_input import DynamicImageInputs
from .color_picker import ColorPicker
from .remove_empty_lines import RemoveEmptyLinesAndLeadingSpaces
# 节点映射
NODE_CLASS_MAPPINGS = {
"ImageResolutionAdjuster": ImageResolutionAdjuster,
# "DynamicImageInputs": DynamicImageInputs,
"RemoveEmptyLinesAndLeadingSpaces": RemoveEmptyLinesAndLeadingSpaces,
"ColorPicker": ColorPicker,
"RemoveEmptyLinesAndLeadingSpaces": RemoveEmptyLinesAndLeadingSpaces
}
NODE_DISPLAY_NAME_MAPPINGS = {
"ImageResolutionAdjuster": "Image Resolution Adjuster",
# "DynamicImageInputs": "Dynamic Image Inputs",
"RemoveEmptyLinesAndLeadingSpaces": "Remove Empty Lines And LeadingSpaces",
"ColorPicker": "Color Picker",
"RemoveEmptyLinesAndLeadingSpaces": "Remove Empty Lines And Leading Spaces"
}
except ImportError as e:
print(f"Error importing modules: {e}")
Binary file not shown.
Binary file not shown.
+44
View File
@@ -0,0 +1,44 @@
import torch
import numpy as np
from PIL import Image
class ColorPicker:
"""
颜色选择器节点,使用 jscolor 实现颜色选择和吸管工具
"""
def __init__(self):
self.color = "#000000"
@classmethod
def INPUT_TYPES(s):
return {"required": {}} # 不需要输入项
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("color",)
FUNCTION = "pick_color"
CATEGORY = "🎨Painting👓Coder/🎨Color"
def pick_color(self):
return (self.color,)
@classmethod
def VALIDATE_INPUTS(s, **kwargs):
return True
def widget_value_updated(self, widget, value):
if widget.name == "color_picker":
self.color = value
@classmethod
def WIDGETS(s):
return {"color_picker": ("color", {"default": "#000000"})}
# 在 __init__.py 中添加节点注册
NODE_CLASS_MAPPINGS = {
"ColorPicker": ColorPicker
}
NODE_DISPLAY_NAME_MAPPINGS = {
"ColorPicker": "Color Picker"
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 KiB