Add files via upload
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
Parameter Type Description 中文说明
|
||||
control_mode list [increment, decrement, random, fixed] 种子控制模式
|
||||
enable_formatting bool Auto remove empty lines 自动清除空行
|
||||
file_path string e.g.: "D:/comfyui/prompts" 文件路径
|
||||
file_name string e.g.: "style_prompts.txt" 文件名
|
||||
calculate_lines bool Show line count in output 输出显示行数统计
|
||||
seed int Start seed (0-18446744073709551615) 起始种子值
|
||||
|
||||
Mode Description 描述
|
||||
Increment Auto +1 per generation 每次生成自动+1
|
||||
Decrement Auto -1 (≥0) 每次生成自动-1(不低于0)
|
||||
Random Full random 完全随机
|
||||
Fixed Keep original 保持原始种子"# ComfyUI-YK_Line-loading"
|
||||
"# ComfyUI-YK_Line-loading"
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
import os
|
||||
import comfy
|
||||
import nodes
|
||||
from comfy.cli_args import args
|
||||
|
||||
class MultiTextLoader:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"text_input": ("STRING", {"multiline": True, "default": ""}),
|
||||
"enable_formatting": ("BOOLEAN", {"default": True}),
|
||||
"file_path": ("STRING", {"default": ""}),
|
||||
"file_name": ("STRING", {"default": ""}),
|
||||
"calculate_lines": ("BOOLEAN", {"default": True}),
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING", "INT", "INT")
|
||||
RETURN_NAMES = ("text_output", "line_count", "new_seed")
|
||||
FUNCTION = "process_text"
|
||||
CATEGORY = "custom"
|
||||
|
||||
def process_text(self, text_input, enable_formatting, file_path, file_name, calculate_lines, seed):
|
||||
# 读取文件内容
|
||||
full_path = os.path.join(file_path, file_name)
|
||||
file_text = ""
|
||||
if os.path.exists(full_path):
|
||||
try:
|
||||
with open(full_path, "r", encoding="utf-8") as f:
|
||||
file_text = f.read()
|
||||
except:
|
||||
pass
|
||||
|
||||
# 选择文本源
|
||||
text = file_text if file_text.strip() else text_input
|
||||
|
||||
# 自动排版处理
|
||||
if enable_formatting:
|
||||
lines = [line.strip() for line in text.splitlines() if line.strip()]
|
||||
processed_text = "\n".join(lines)
|
||||
else:
|
||||
processed_text = text
|
||||
|
||||
# 分割处理后的文本
|
||||
all_lines = processed_text.splitlines()
|
||||
line_count = len(all_lines)
|
||||
output_line_count = line_count if calculate_lines else 0
|
||||
|
||||
# 选择输出行
|
||||
selected_line = ""
|
||||
if line_count > 0:
|
||||
selected_line = all_lines[seed % line_count]
|
||||
|
||||
# 生成新种子
|
||||
new_seed = seed + 1
|
||||
|
||||
return (selected_line, output_line_count, new_seed)
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"MultiTextLoader": MultiTextLoader
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"MultiTextLoader": "YK_Line loading"
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 73 KiB |
@@ -0,0 +1,264 @@
|
||||
{
|
||||
"last_node_id": 368,
|
||||
"last_link_id": 494,
|
||||
"nodes": [
|
||||
{
|
||||
"id": 329,
|
||||
"type": "easy showAnything",
|
||||
"pos": [
|
||||
-3054.24072265625,
|
||||
1659.815673828125
|
||||
],
|
||||
"size": [
|
||||
468.74237060546875,
|
||||
285.0501403808594
|
||||
],
|
||||
"flags": {},
|
||||
"order": 1,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "anything",
|
||||
"label": "输入任何",
|
||||
"type": "*",
|
||||
"shape": 7,
|
||||
"link": 490
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "output",
|
||||
"label": "output",
|
||||
"type": "*",
|
||||
"links": null
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "easy showAnything",
|
||||
"ttNbgOverride": {
|
||||
"color": "#223",
|
||||
"bgcolor": "#335",
|
||||
"groupcolor": "#88A"
|
||||
}
|
||||
},
|
||||
"widgets_values": [
|
||||
""
|
||||
],
|
||||
"color": "#223",
|
||||
"bgcolor": "#335"
|
||||
},
|
||||
{
|
||||
"id": 342,
|
||||
"type": "easy showAnything",
|
||||
"pos": [
|
||||
-3044.742919921875,
|
||||
1990.27001953125
|
||||
],
|
||||
"size": [
|
||||
468.74237060546875,
|
||||
285.0501403808594
|
||||
],
|
||||
"flags": {},
|
||||
"order": 2,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "anything",
|
||||
"label": "输入任何",
|
||||
"type": "*",
|
||||
"shape": 7,
|
||||
"link": 491
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "output",
|
||||
"label": "output",
|
||||
"type": "*",
|
||||
"links": null
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "easy showAnything",
|
||||
"ttNbgOverride": {
|
||||
"color": "#223",
|
||||
"bgcolor": "#335",
|
||||
"groupcolor": "#88A"
|
||||
}
|
||||
},
|
||||
"widgets_values": [
|
||||
"0"
|
||||
],
|
||||
"color": "#223",
|
||||
"bgcolor": "#335"
|
||||
},
|
||||
{
|
||||
"id": 368,
|
||||
"type": "easy showAnything",
|
||||
"pos": [
|
||||
-3044.388427734375,
|
||||
2320.8623046875
|
||||
],
|
||||
"size": [
|
||||
468.74237060546875,
|
||||
285.0501403808594
|
||||
],
|
||||
"flags": {},
|
||||
"order": 3,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "anything",
|
||||
"label": "输入任何",
|
||||
"type": "*",
|
||||
"shape": 7,
|
||||
"link": 492
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "output",
|
||||
"label": "output",
|
||||
"type": "*",
|
||||
"links": null
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "easy showAnything",
|
||||
"ttNbgOverride": {
|
||||
"color": "#223",
|
||||
"bgcolor": "#335",
|
||||
"groupcolor": "#88A"
|
||||
}
|
||||
},
|
||||
"widgets_values": [
|
||||
"21"
|
||||
],
|
||||
"color": "#223",
|
||||
"bgcolor": "#335"
|
||||
},
|
||||
{
|
||||
"id": 367,
|
||||
"type": "MultiTextLoader",
|
||||
"pos": [
|
||||
-3638.96337890625,
|
||||
1818.798583984375
|
||||
],
|
||||
"size": [
|
||||
481.9922180175781,
|
||||
450.3727111816406
|
||||
],
|
||||
"flags": {},
|
||||
"order": 0,
|
||||
"mode": 0,
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "text_output",
|
||||
"label": "text_output",
|
||||
"type": "STRING",
|
||||
"links": [
|
||||
490
|
||||
],
|
||||
"slot_index": 0
|
||||
},
|
||||
{
|
||||
"name": "line_count",
|
||||
"label": "line_count",
|
||||
"type": "INT",
|
||||
"links": [
|
||||
491
|
||||
],
|
||||
"slot_index": 1
|
||||
},
|
||||
{
|
||||
"name": "new_seed",
|
||||
"label": "new_seed",
|
||||
"type": "INT",
|
||||
"links": [
|
||||
492
|
||||
],
|
||||
"slot_index": 2
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "MultiTextLoader",
|
||||
"ttNbgOverride": {
|
||||
"color": "#223",
|
||||
"bgcolor": "#335",
|
||||
"groupcolor": "#88A"
|
||||
}
|
||||
},
|
||||
"widgets_values": [
|
||||
"",
|
||||
true,
|
||||
"C:\\Users\\Administrator\\Desktop\\03\\33",
|
||||
"新建文本文档",
|
||||
true,
|
||||
21,
|
||||
"increment",
|
||||
[
|
||||
false,
|
||||
true
|
||||
]
|
||||
],
|
||||
"color": "#223",
|
||||
"bgcolor": "#335"
|
||||
}
|
||||
],
|
||||
"links": [
|
||||
[
|
||||
470,
|
||||
331,
|
||||
0,
|
||||
328,
|
||||
0,
|
||||
"*"
|
||||
],
|
||||
[
|
||||
490,
|
||||
367,
|
||||
0,
|
||||
329,
|
||||
0,
|
||||
"*"
|
||||
],
|
||||
[
|
||||
491,
|
||||
367,
|
||||
1,
|
||||
342,
|
||||
0,
|
||||
"*"
|
||||
],
|
||||
[
|
||||
492,
|
||||
367,
|
||||
2,
|
||||
368,
|
||||
0,
|
||||
"*"
|
||||
]
|
||||
],
|
||||
"groups": [],
|
||||
"config": {},
|
||||
"extra": {
|
||||
"ds": {
|
||||
"scale": 0.9646149645000014,
|
||||
"offset": {
|
||||
"0": 3955.791748046875,
|
||||
"1": -1599.64208984375
|
||||
}
|
||||
},
|
||||
"ue_links": [],
|
||||
"groupNodes": {},
|
||||
"node_versions": {
|
||||
"ComfyUI-Easy-Use": "aadbb0b38945eba3e15be6099a7f4e5c0327c175"
|
||||
},
|
||||
"VHS_latentpreview": false,
|
||||
"VHS_latentpreviewrate": 0,
|
||||
"VHS_MetadataImage": true,
|
||||
"VHS_KeepIntermediate": true
|
||||
},
|
||||
"version": 0.4
|
||||
}
|
||||
Reference in New Issue
Block a user