Skip to content

Commit be179ab

Browse files
committed
added the TextInputAutoSelector node.
1 parent 905586c commit be179ab

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ Modified the [image-resize-comfyui](https://github.com/palant/image-resize-comfy
6363
## TextPreview
6464
Added the node for convenience. The code is originally from ComfyUI-Custom-Scripts, thanks.
6565

66+
## TextInputAutoSelector
67+
Check the component and alternative input. If the component input is not empty, return this text; otherwise, return the alternative text.
68+
6669
## MatchImageRatioToPreset
6770
According to the input image ratio, decide which standard SDXL training size is the closest match. This is useful for subsequent image resizing and other processes.
6871

py/nodes.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,34 @@ def notify(self, text, unique_id=None, extra_pnginfo=None):
10421042

10431043
return {"ui": {"text": text}, "result": (text,)}
10441044

1045+
class TextInputAutoSelector:
1046+
@classmethod
1047+
def INPUT_TYPES(s):
1048+
return {
1049+
"required": {
1050+
"component_input": ("STRING", {"multiline": True}),
1051+
},
1052+
"optional":{
1053+
"alternative_input": ("STRING",{"forceInput": True}),
1054+
}
1055+
}
1056+
1057+
RETURN_TYPES = ("STRING",)
1058+
FUNCTION = "select_input"
1059+
CATEGORY = "utils/text"
1060+
1061+
def select_input(self, component_input, alternative_input=""):
1062+
# 去除组件输入两端的空白字符
1063+
component_input = component_input.strip()
1064+
1065+
# 如果组件输入为空或只包含空白字符,选择外部输入
1066+
if not component_input:
1067+
selected_input = alternative_input
1068+
else:
1069+
selected_input = component_input
1070+
1071+
return (selected_input,)
1072+
10451073

10461074
class MatchImageRatioToPreset:
10471075
def __init__(self):
@@ -1139,6 +1167,7 @@ def forward(self, image, upscale_model, threshold_of_xl_area=0.9):
11391167
"ModifyTextGender": ModifyTextGender,
11401168
"GenderControlOutput": GenderControlOutput,
11411169
"TextPreview": TextPreview,
1170+
"TextInputAutoSelector": TextInputAutoSelector,
11421171

11431172
# numbers
11441173
"MatchImageRatioToPreset": MatchImageRatioToPreset,
@@ -1174,6 +1203,7 @@ def forward(self, image, upscale_model, threshold_of_xl_area=0.9):
11741203
"ModifyTextGender": "Modify Text Gender",
11751204
"GenderControlOutput": "Gender Control Output",
11761205
"TextPreview": "Preview Text",
1206+
"TextInputAutoSelector": "Text Input Auto Selector",
11771207

11781208
# Number
11791209
"MatchImageRatioToPreset": "Match Image Ratio to Standard Size",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "comfyui-utils-nodes"
33
description = "Nodes:LoadImageWithSwitch, ImageBatchOneOrMore, ModifyTextGender, GenderControlOutput, ImageCompositeMaskedWithSwitch, ColorCorrectOfUtils, SplitMask, MaskFastGrow, CheckpointLoaderSimpleWithSwitch, ImageResizeTo8x, MatchImageRatioToPreset, UpscaleImageWithModelIfNeed, MaskFromFaceModel, MaskCoverFourCorners, DetectorForNSFW, DeepfaceAnalyzeFaceAttributes etc."
4-
version = "1.1.6"
4+
version = "1.1.7"
55
license = { file = "LICENSE" }
66
dependencies = []
77

0 commit comments

Comments
 (0)