Files
aigc-home/docs/hel-892/qwen21-control-document-evidence/build_definition.py
T

979 lines
40 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"Pinned Qwen Image2.1 static reference; no upstream import, prompt construction or execution."
import ast
import hashlib
import json
from pathlib import Path
REPO = Path(__file__).resolve().parents[3]
OUT = Path(__file__).resolve().parent
REF = OUT.parent / "qwen21-control-reference"
PATHS = [
"example_ComfyUI_workflows/3-图像生成/Qwen-Image-2.1/Qwen_image2.1_图像编辑_深度-姿势-线稿-硬边缘-控图洗图.json"
]
HOST = "23694d89-9fa2-4beb-a712-55beda8c219b"
LAYOUTS = {
"LoadImage": ["image", "upload"],
"CLIPLoader": ["clip_name", "type", "device"],
"VAELoader": ["vae_name"],
"UNETLoader": ["unet_name", "weight_dtype"],
"GoohaiRouteBlocker": ["是否阻断", "阻断模式"],
"TextEncodeQwenImage21GH": [
"prompt",
"negative_prompt",
"latent_width",
"latent_height",
"mode",
"ref_image_size",
],
"GoohaiRatioAndResolution": [
"比例",
"模式",
"固定边像素",
"百万像素",
"长边最小",
"长边最大",
"自定宽度",
"自定高度",
"倍数取整",
],
"忽略多组孤海": ["guhai_ig"],
"GetNode": ["Constant"],
"SetNode": ["Constant"],
"KSampler": [
"seed",
"seed_control_candidate",
"steps",
"cfg",
"sampler_name",
"scheduler",
"denoise",
],
"ShowText|pysssss": ["text_0"],
"Image Comparer (rgthree)": ["rgthree_comparer"],
"QwenImagePromptOptimizer": [
"用户提示词",
"文生图模型",
"图生图模型",
"视觉模型",
"输出语言",
"透明背景",
"种子值",
"种子模式",
"卸载模型",
],
"SaveImage": ["filename_prefix"],
"QwenImage21Cache": ["device", "dtype"],
"PrimitiveStringMultiline": ["value"],
"LoraLoaderModelOnly": ["lora_name", "strength_model"],
}
LABELS = {
"filename_prefix": "正式保存前缀",
"aspect_ratio": "宽高比保存选择",
"megapixels": "目标MP保存值",
"multiple": "像素对齐倍数",
"value": "完整文本/布尔保存值",
"value_1": "宿主提示增强缓存",
"max_length": "最大文本长度保存值",
"width": "宽度缓存",
"height": "高度缓存",
"seed": "种子缓存",
"value_2": "宿主LoRA启用缓存",
"lora_name": "LoRA文件引用",
"strength_model": "LoRA强度",
"string_b": "完整字符串B缓存/触发词",
"unet_name": "扩散模型文件引用",
"clip_name": "文本模型文件引用",
"vae_name": "VAE文件引用",
"text": "完整文本/历史保存值",
"batch_size": "latent批量",
"seed_control_candidate": "前端种子控制辅助",
"steps": "采样步数",
"cfg": "引导系数",
"sampler_name": "采样器",
"scheduler": "调度器",
"denoise": "降噪系数",
"weight_dtype": "权重类型",
"type": "编码器类型(枚举冲突)",
"device": "设备选择",
"prompt": "完整生成文本缓存",
"sampling_mode": "动态采样模式保存分支",
"sampling_mode.temperature": "on分支温度",
"sampling_mode.top_k": "on分支Top K",
"sampling_mode.top_p": "on分支Top P",
"sampling_mode.min_p": "on分支Min P",
"sampling_mode.repetition_penalty": "on分支重复惩罚",
"sampling_mode.seed": "on分支文本生成种子",
"sampling_mode.presence_penalty": "on分支presence penalty",
"thinking": "思考模式保存值",
"use_default_template": "默认模板保存值",
"switch": "布尔选择缓存",
"string_a": "完整字符串A缓存",
"delimiter": "完整分隔符",
}
LABELS.update(
{
"thinking": "思考模式保存值",
"value_3": "宿主LoRA开关缓存",
"width_1": "宿主宽度缓存",
"height_1": "宿主高度缓存",
"seed_1": "宿主种子缓存",
"lora_name_1": "宿主LoRA文件引用",
"strength_model_1": "宿主LoRA强度",
"string_b_1": "宿主追加串缓存",
"unet_name_1": "宿主扩散模型引用",
"clip_name_1": "宿主文本模型引用",
"vae_name_1": "宿主VAE引用",
"Constant": "完整名称保存参考",
"prefix": "前缀选择保存值",
"subject": "主体选择保存值",
"action": "动作选择保存值",
"clothes": "衣着选择保存值",
"environment": "光照选择保存值",
"background": "背景选择保存值",
"nsfw": "内容类别选择保存值",
"styles": "风格分类引用",
"select_styles": "风格选择保存值",
"Select to add LoRA": "LoRA添加控件保存值",
"Select to add Wildcard": "外卡添加控件保存值",
"multiline_mode": "多行模式选择",
}
)
LABELS.update(
{
"inputcount": "动态输入数量",
"return_list": "返回列表选择",
"frontend_update_null": "前端末尾null保存",
"history_images": "完整空历史列表",
"Constant": "保存名称参考",
"use_custom_resolution": "自定义尺寸选择",
"resolution": "尺寸预设",
"custom_width": "自定义宽度缓存",
"custom_height": "自定义高度缓存",
"noise_seed": "噪声种子缓存",
"frontend_last_seed": "前端辅助空串1",
"frontend_new_seed": "前端辅助空串2",
"frontend_control": "前端辅助空串3",
"aspect_ratio": "比例选择",
"proportional_width": "自定义比例宽",
"proportional_height": "自定义比例高",
"fit": "图像适配模式",
"method": "缩放插值选择",
"round_to_multiple": "倍数选择(字符串)",
"scale_to_side": "缩放边选择",
"scale_to_length": "目标边长度缓存",
"background_color": "背景色",
"purge_cache": "清理缓存选择",
"purge_models": "清理模型选择",
"reserved": "预留显存接口值",
"auto_max_reserved": "自动预留上限",
"clean_gpu_before": "前置清理选择",
"cleanup_threshold": "最小空闲RAM接口值",
"model": "宿主/内部模型引用",
"mmproj": "投影文件引用",
"chat_handler": "聊天处理器保存",
"max_tokens": "最大输出token缓存",
"preset_prompt": "预设提示选择",
"custom_prompt": "完整自定义提示缓存",
"system_prompt": "完整系统指南缓存",
"inference_mode": "推理输入模式",
"n_ctx": "上下文保存值",
"vram_limit": "显存限制保存值",
"image_min_tokens": "最小图像token保存",
"image_max_tokens": "最大图像token保存",
"present_penalty": "原拼present_penalty保存",
"top_k": "Top K保存",
"top_p": "Top P保存",
"min_p": "Min P保存",
"typical_p": "Typical P保存",
"temperature": "温度保存",
"repeat_penalty": "重复惩罚保存",
"frequency_penalty": "频率惩罚保存",
"mirostat_mode": "Mirostat模式保存",
"mirostat_eta": "Mirostat eta保存",
"mirostat_tau": "Mirostat tau保存",
"state_uid": "状态标识保存",
"max_frames": "最大帧保存",
"max_size": "最大尺寸保存",
"force_offload": "强制卸载保存",
"save_states": "状态保存选择",
"text": "完整文本保存值",
"type": "编码器类型保存",
}
)
LABELS.update(
{
"image": "图像文件保存引用",
"upload": "前端上传控件状态",
"text_0": "完整历史显示文本",
"rgthree_comparer": "位置历史与具名完整形态",
"是否阻断": "是否阻断保存缓存",
"阻断模式": "阻断模式保存",
"latent_width": "latent宽度缓存",
"latent_height": "latent高度缓存",
"negative_prompt": "完整负向保存",
"ref_image_size": "参考图尺寸选择保存",
"比例": "比例保存选择",
"模式": "尺寸模式保存",
"固定边像素": "固定边保存值",
"百万像素": "MP保存值",
"长边最小": "长边下限保存",
"长边最大": "长边上限保存",
"自定宽度": "自定义宽度保存",
"自定高度": "自定义高度保存",
"倍数取整": "倍数选择保存",
"guhai_ig": "组控制前端空串保存",
"用户提示词": "用户提示词缓存",
"文生图模型": "文生模型保存引用",
"图生图模型": "图生模型保存引用",
"视觉模型": "视觉投影保存引用",
"输出语言": "输出语言保存",
"透明背景": "透明背景保存",
"种子值": "优化器种子保存",
"种子模式": "优化器种子模式保存",
"卸载模型": "模型卸载保存选择",
"dtype": "缓存dtype选择",
"device": "设备选择",
"value": "完整中文提示保存",
}
)
LAYOUTS.update(
{
HOST: [
"resolution",
"prompt",
"switch_1",
"negative_prompt",
"cfg",
"steps",
"switch",
"width",
"height",
"scheduler",
"scheduler_1",
"seed",
"unet_name",
"clip_name",
"vae_name",
"device",
"dtype",
"clip_name_1",
],
"StringConcatenate": ["string_a", "string_b", "delimiter"],
"ResolutionSelector": ["aspect_ratio", "megapixels", "multiple"],
"SaveImageAdvanced": [
"filename_prefix",
"format",
"format.bit_depth",
"format.input_color_space",
],
"VOSR2ModelLoader": ["model", "dtype"],
"VOSR2Upscale": [
"upscale",
"seed",
"fixed",
"color_alignment",
"tile_size",
"tile_overlap",
"vae_tile_size",
"vae_tile_overlap",
],
"GH_ImageVideoComparer": ["gh_image_video_comparer"],
"TextEncodeQwenImage21": ["prompt", "negative_prompt", "resolution"],
"EmptyLatentImage": ["width", "height", "batch_size"],
"TextGenerate": [
"prompt",
"max_length",
"sampling_mode",
"sampling_mode.temperature",
"sampling_mode.top_k",
"sampling_mode.top_p",
"sampling_mode.min_p",
"sampling_mode.repetition_penalty",
"sampling_mode.seed",
"sampling_mode.presence_penalty",
"thinking",
"use_default_template",
"mtp",
],
"PreviewAny": [],
"ComfySwitchNode": ["switch"],
}
)
LAYOUTS.update(
{
"SaveImageAdvanced": [
"filename_prefix",
"format",
"format.bit_depth",
"format.input_color_space",
],
"LoadImage": ["image", "upload"],
"82296023-8cad-4454-9020-339570cedc2c": [
"resolution_level",
"batch_size",
"output",
"model_name",
],
"Image Comparer (rgthree)": ["rgthree_comparer"],
"3aeaa78c-6341-4b9f-aded-e3be0df01b1e": [
"draw_body",
"draw_hands",
"draw_face",
"draw_feet",
"stick_width",
"face_point_size",
"score_threshold",
"ckpt_name",
],
"e69cd71f-07c6-4740-a173-aaac13d4ec0b": [
"resolution_level",
"batch_size",
"output",
"model_name",
],
"AnyLineArtPreprocessor_aux": [
"merge_with_lineart",
"resolution",
"lineart_lower_bound",
"lineart_upper_bound",
"object_min_size",
"object_connectivity",
],
"23694d89-9fa2-4beb-a712-55beda8c219b": [
"resolution",
"prompt",
"switch_1",
"negative_prompt",
"cfg",
"steps",
"switch",
"width",
"height",
"scheduler",
"scheduler_1",
"seed",
"unet_name",
"clip_name",
"vae_name",
"device",
"dtype",
"clip_name_1",
],
"AIO_Preprocessor": ["preprocessor", "resolution"],
"PrimitiveStringMultiline": ["value"],
"ResolutionSelector": ["aspect_ratio", "megapixels", "multiple"],
"LoadMoGeModel": ["model_name"],
"MoGeInference": [
"resolution_level",
"fov_x_degrees",
"batch_size",
"force_projection",
"apply_mask",
"refine_steps",
],
"MoGeRender": ["output"],
"SDPoseKeypointExtractor": ["batch_size"],
"ResizeImageMaskNode": ["resize_type", "resize_type.longer_size", "scale_method"],
"SDPoseDrawKeypoints": [
"draw_body",
"draw_hands",
"draw_face",
"draw_feet",
"stick_width",
"face_point_size",
"score_threshold",
"draw_head",
],
"CheckpointLoaderSimple": ["ckpt_name"],
"UNETLoader": ["unet_name", "weight_dtype"],
"CLIPLoader": ["clip_name", "type", "device"],
"VAELoader": ["vae_name"],
"EmptyLatentImage": ["width", "height", "batch_size"],
"KSampler": [
"seed",
"seed_control_candidate",
"steps",
"cfg",
"sampler_name",
"scheduler",
"denoise",
],
"ComfySwitchNode": ["switch"],
"QwenImage21Cache": ["device", "dtype"],
"TextEncodeQwenImage21": ["prompt", "negative_prompt", "resolution"],
"TextGenerate": [
"prompt",
"max_length",
"sampling_mode",
"sampling_mode.temperature",
"sampling_mode.top_k",
"sampling_mode.top_p",
"sampling_mode.min_p",
"sampling_mode.repetition_penalty",
"sampling_mode.seed",
"sampling_mode.presence_penalty",
"thinking",
"use_default_template",
"mtp",
],
}
)
def canonical(v):
return json.dumps(v, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode()
def build(index=0):
raw = (REPO / PATHS[index]).read_bytes()
g = json.loads(raw)
editorial = json.loads((OUT / "editorial.json").read_bytes())
host_ids = {
d["id"]: str(next(n["id"] for n in g["nodes"] if n["type"] == d["id"]))
for d in g["definitions"]["subgraphs"]
}
scopes = [("", "", g)] + [
(host_ids[d["id"]], f"/definitions/subgraphs/{i}", d)
for i, d in enumerate(g["definitions"]["subgraphs"])
]
nodes = [
((pre + ":" if pre else "") + str(n["id"]), ptr + f"/nodes/{i}", pre or "root", n)
for (pre, ptr, graph) in scopes
for (i, n) in enumerate(graph["nodes"])
]
manifest = json.loads((REF / "sources.json").read_bytes())["sources"]
sources = []
trees = {}
for e in manifest:
data = (REF / e["local_file"]).read_bytes()
assert hashlib.sha256(data).hexdigest() == e["sha256"]
sources.append(
dict(
e,
local_file="../qwen21-control-reference/" + e["local_file"],
lines=[1, len(data.decode().splitlines())],
claim="本图准确tag/commit原文与许可;静态读取未执行,源码许可不等于模型许可",
)
)
if e["file"].endswith(".py"):
trees[e["local_file"]] = ast.parse(data)
bindings = []
prose = json.loads((OUT / "prose.json").read_bytes())
refs = {}
schemas = {}
for nid, ptr, scope, n in nodes:
cls = n["type"]
if cls in ["Note", "MarkdownNote"]:
continue
symbol = {
"PrimitiveStringMultiline": "StringMultiline",
"ShowText|pysssss": "ShowText",
"Image Comparer (rgthree)": "RgthreeImageComparer",
"ComfySwitchNode": "SwitchNode",
"Images to RGB": "WAS_Images_To_RGB",
"AnyLineArtPreprocessor_aux": "AnyLinePreprocessor",
"忽略多组孤海": "IgnoreGroupsGuHai",
"GH_ImageVideoComparer": "GHImageVideoComparer",
}.get(cls, cls)
version = n.get("properties", {}).get("ver", "未知")
core_id = {
"0.15.0": "core0150",
"1.1.5": "aux",
"449c58fcdd612f7733e54c51f6758ead63fa180b": "rgthree",
"0.38.0": "core0380",
"61425dc193e3714492d840150e30926d16e567f0": "ghcompare",
}.get(version, "unknown")
if cls in host_ids:
core_id = "subgraph-definition"
candidates = []
rs = []
for i, e in enumerate(manifest):
if e["id"] != core_id or not e["file"].endswith(".py"):
continue
if cls == "KSampler" and e["file"] != "nodes.py":
continue
for c in trees[e["local_file"]].body:
if not isinstance(c, ast.ClassDef) or c.name != symbol:
continue
sources.append(
dict(
sources[i],
lines=[c.lineno, c.end_lineno],
claim=f"本节点准确{core_id}声明类实现;不等于目标安装或宿主恢复认证",
)
)
rs += [i, len(sources) - 1]
candidates.append(dict(source=i, symbol=symbol, lines=[c.lineno, c.end_lineno]))
if cls in ["LoraLoaderModelOnly", "PreviewImage"]:
parent = next(
p
for p in trees[e["local_file"]].body
if isinstance(p, ast.ClassDef)
and p.name
== ("LoraLoader" if cls == "LoraLoaderModelOnly" else "SaveImage")
)
sources.append(
dict(
sources[i],
lines=[parent.lineno, parent.end_lineno],
claim=f"本节点准确{core_id}父类及加载条件;只静态读取",
)
)
rs.append(len(sources) - 1)
for call in ast.walk(c):
if (
isinstance(call, ast.Call)
and isinstance(call.func, ast.Name)
and call.func.id == "define_preprocessor_inputs"
):
for kw in call.keywords:
if isinstance(kw.value, ast.Call):
default = next(
(
ast.unparse(k.value)
for k in kw.value.keywords
if k.arg == "default"
),
"准确helper缺省见utils.py",
)
schemas[nid, kw.arg] = (default, ast.unparse(kw.value))
for d in ast.walk(c):
if isinstance(d, ast.Dict):
for k, v in zip(d.keys, d.values, strict=True):
if (
isinstance(k, ast.Constant)
and isinstance(k.value, str)
and isinstance(v, ast.Tuple)
):
default = "无显式default;动态枚举/方法条件只作参考"
for opts in v.elts[1:]:
if isinstance(opts, ast.Dict):
for dk, dv in zip(opts.keys, opts.values, strict=True):
if (
isinstance(dk, ast.Constant)
and dk.value == "default"
):
default = ast.unparse(dv)
schemas[nid, k.value] = (default, ast.unparse(v))
if (
isinstance(d, ast.Call)
and isinstance(d.func, ast.Attribute)
and (d.func.attr == "Input")
):
arg = (
d.args[0]
if d.args
else next((k.value for k in d.keywords if k.arg == "id"), None)
)
if not isinstance(arg, ast.Constant) or not isinstance(arg.value, str):
continue
name = arg.value
if cls == "TextGenerate" and name in [
"temperature",
"top_k",
"top_p",
"min_p",
"repetition_penalty",
"seed",
"presence_penalty",
]:
name = "sampling_mode." + name
default = next(
(ast.unparse(k.value) for k in d.keywords if k.arg == "default"),
"无显式default,不从execute函数缺省补值",
)
if cls == "SaveImageAdvanced" and name in [
"bit_depth",
"input_color_space",
]:
# Keep the first exact PNG DynamicCombo branch.
schemas.setdefault((nid, "format." + name), (default, ast.unparse(d)))
else:
schemas[nid, name] = (default, ast.unparse(d))
assert len(candidates) <= 1, (nid, candidates)
if not candidates and core_id not in ["unknown", "subgraph-definition"]:
core_id = "unresolved-" + core_id
bindings.append(
dict(
node_id=nid,
class_type=cls,
source_version=version,
source_id=core_id,
candidates=candidates,
)
)
if core_id.replace("unresolved-", "") in [
"goohai",
"rgthree",
"showtext",
"ghgroup",
"ghcompare",
"was",
"vosr",
]:
rs += [
i for i, e in enumerate(manifest) if e["id"] == core_id.replace("unresolved-", "")
]
if cls == "KSampler":
rs += [
i
for i, e in enumerate(manifest)
if e["id"] == core_id and e["file"] == "comfy/samplers.py"
]
if cls in [
"KSampler",
"LoadImage",
"ShowText|pysssss",
"Image Comparer (rgthree)",
"忽略多组孤海",
]:
rs += [i for i, e in enumerate(manifest) if e["id"] in ["frontend", "litegraph"]]
if cls == "QwenImage21Cache":
rs += [
i
for i, e in enumerate(manifest)
if e["id"] == core_id
and e["file"].startswith(("comfy/ldm/qwen_image21/", "comfy_api/latest/"))
]
rs += [i for i, e in enumerate(manifest) if e["id"] == core_id.removeprefix("unresolved-")]
rs += [i for i, e in enumerate(manifest) if e["id"] == "frontend"]
refs[nid] = list(dict.fromkeys(rs))
fields = []
comments = []
flow = []
empty = []
for nid, ptr, scope, n in nodes:
cls = n["type"]
if cls in ["Note", "MarkdownNote"]:
comments.append(
dict(
node_id=nid,
pointer=ptr + "/widgets_values/0",
text=n["widgets_values"][0],
meaning=prose["notes"][nid],
named_pointer=ptr + "/widgets_values_named/text",
named_value=n["widgets_values_named"]["text"],
evidence=[],
)
)
flow.append(nid + " 原注释节点 " + json.dumps(n, ensure_ascii=False))
continue
core_id = next(b["source_id"] for b in bindings if b["node_id"] == nid)
effect = (
editorial[nid]
+ " 原mode="
+ str(n["mode"])
+ (
"(旁路保存态,不模拟穿透或执行)。"
if n["mode"] == 4
else "(mode2禁用/忽略保存态,不模拟组控制或执行)。"
if n["mode"] == 2
else "(活动保存态,不认证执行)。"
)
)
flow += [
effect,
nid + " 原属性 " + json.dumps(n.get("properties", {}), ensure_ascii=False),
nid
+ " 原输入/输出 "
+ json.dumps({k: n[k] for k in ["inputs", "outputs"]}, ensure_ascii=False),
nid
+ " 原具名保存 "
+ json.dumps(n.get("widgets_values_named", "missing"), ensure_ascii=False),
nid
+ " 原其它属性 "
+ json.dumps(
{
k: v
for k, v in n.items()
if k
not in [
"inputs",
"outputs",
"properties",
"widgets_values",
"widgets_values_named",
]
},
ensure_ascii=False,
),
]
if not n.get("widgets_values"):
empty.append(
dict(
node_id=nid,
class_type=cls,
pointer=ptr,
scope=scope,
state="missing" if "widgets_values" not in n else "empty_list",
effect=effect,
named_state="empty_object"
if n.get("widgets_values_named") == {}
else "missing",
)
)
continue
for j, (name, value) in enumerate(zip(LAYOUTS[cls], n["widgets_values"], strict=True)):
found = [i for (i, x) in enumerate(n["inputs"]) if x["name"] == name]
inp = found[0] if len(found) == 1 else None
linked = inp is not None and n["inputs"][inp].get("link") is not None
boundary = cls in host_ids
aux = name in [
"seed_control_candidate",
"fixed",
"upload",
"text_0",
"rgthree_comparer",
"guhai_ig",
]
(default, limits) = schemas.get(
(nid, name),
(
"无准确独立宿主/前端widget默认",
"宿主保存位置/声明边界,不认证promoted或后端执行映射",
),
)
unit = "无物理单位;文本/枚举/标识/布尔接口参考,实际环境未核"
if core_id == "unknown" or core_id.startswith("unresolved-"):
default = "未知:未核准本声明准确类/schema,不由保存值或其它版本推定"
limits = "仅源位置/具名保存/声明输入候选;准确默认、范围、算法、恢复和副作用未知"
unit = "未知:准确类/schema未核,不推定单位或实际效果"
if name in ["seed", "steps"]:
unit = "整数数量/种子索引;不执行时序或保证效果"
if name in ["cfg", "denoise", "strength_model"]:
unit = "无物理单位的接口系数,准确范围见源码,不保证效果"
if name in ["seed_control_candidate", "fixed"]:
default = "准确frontend1.53.6辅助缺省randomize,非后端seed参数"
limits = "fixed/increment/decrement/randomize;不执行种子控制或认证恢复"
if name == "upload":
default = "前端上传控件状态,不是后端图像数据默认"
limits = "保存image状态与后端image文件选择分列;不上传、打开或读取媒体"
if name == "text_0":
default = "前端保存历史显示,无text_0后端默认,不是本次优化结果"
limits = (
"准确ShowText发布成员/前端写回参考;完整1425文本和具名text_0保留,不当本次输出"
)
if name == "rgthree_comparer":
default = "前端完整历史列表,非当前产物或后端输入默认"
limits = (
"位置列表与具名images/额外img对象分别全文保留;"
"源出口声明与准确UI/data返回分列;不请求历史媒体"
)
if cls in ["SetNode", "GetNode"]:
limits += ";无cnr/ver,仅aux/名称/previousName/物理口,不认证全局别名或配对恢复"
if cls == "QwenImage21Cache":
limits += ";是否注册/模型patch及设备dtype条件只按本版源码,不借新版或执行缓存"
if cls == "SaveImageAdvanced" and name in [
"format.bit_depth",
"format.input_color_space",
]:
default = "'8-bit'" if name.endswith("bit_depth") else "'sRGB'"
limits = (
"准确PNG分支:bit_depth枚举8-bit/16-bit默认8-bit,"
"input_color_space仅sRGB默认sRGB;与EXR/AVIF分支分列,不保证真实通道/色彩。"
)
if cls in host_ids:
default = "无独立宿主schema默认,不把缓存或内部默认等同最终输入"
limits = (
f"本宿主{len(n['widgets_values'])}缓存/{len(n['inputs'])}输入与当前定义边界分列;"
"准确前端1.53.6静态参考,UE/宿主恢复未认证"
)
if cls == "VOSR2Upscale" and name == "fixed":
default = "准确VOSR2 seed声明control_after_generate=io.ControlAfterGenerate.fixed"
limits = "源码seed辅助缺省fixed,与seed整数参数分列;不执行前端种子时序或随机"
unit = "前端种子控制枚举,无物理单位"
if name in [
"width",
"height",
"tile_size",
"tile_overlap",
"vae_tile_size",
"vae_tile_overlap",
]:
unit = "像素尺寸/重叠长度;保存缓存与连线覆盖分列,不计算实际尺寸"
if cls == "TextEncodeQwenImage21" and name == "resolution":
unit = "参考图预处理像素标尺;不是EmptyLatentImage宽高,不认证实际处理"
if cls == "ResolutionSelector" and name == "megapixels":
unit = "MP,准确实现以1024×1024为基数;源JSON int1与默认1.0分列,不试算尺寸"
if cls == "ResolutionSelector" and name == "multiple":
unit = "像素对齐倍数;准确实现round到最近倍数,不计算最终像素"
if name == "upscale":
unit = "无量纲放大倍率;源JSON int2与准确默认4分列,不保证质量/效果"
if name == "max_length":
unit = "文本生成最大token数接口;保存16256与默认512分列,不执行生成"
if name.startswith("sampling_mode."):
unit = "无物理单位的采样参数/计数/种子索引;准确默认范围见源码,不执行随机"
if name == "format.bit_depth":
unit = "PNG每通道位深枚举;8-bit/16-bit分支,不证明实际目标色深"
if core_id == "unknown" or core_id.startswith("unresolved-"):
default = "未知:准确声明版本未核准本类/schema,不借后版或保存值推定"
limits = (
"仅源保存位置/具名/输入口与作者建议;"
"准确默认、范围、0特殊条件、算法和副作用未知"
)
unit = "未知:准确类/schema未核,不推定单位或实际效果"
if core_id in ["core0380", "aux"] and cls == "MoGeInference":
unit = (
"度;0由准确实现自动恢复FOV"
if name == "fov_x_degrees"
else "接口计数/布尔;范围与条件按准确schema,不执行几何推理"
)
if core_id == "aux":
limits += (
";INPUT helper:INT默认0/min0/max16384/step1,"
"FLOAT默认0/min0/max1/step0.01,"
"RESOLUTION默认512/min64/max16384/step64;"
"显式参数覆盖helper缺省;不执行预处理。"
)
if cls == "AIO_Preprocessor" and name == "resolution":
default = "512"
unit = (
"预处理像素标尺,非最终输出尺寸"
if name == "resolution"
else "预处理接口选择/阈值/数量,按准确helper及类定义,不保证图像效果"
)
named_key = "control_after_generate" if name == "seed_control_candidate" else name
named = n["widgets_values_named"][named_key]
display_effect = effect
if canonical(value) != canonical(named):
display_effect += "\n具名保存完整形态(与位置历史分列):" + json.dumps(
named, ensure_ascii=False, indent=2
)
fields.append(
dict(
node_id=nid,
definition_node_id=str(n["id"]),
scope=scope,
class_type=cls,
field=name,
label=LABELS.get(name, name + "完整保存值"),
pointer=f"{ptr}/widgets_values/{j}",
value=value,
json_type=type(value).__name__,
named_pointer=ptr
+ "/widgets_values_named/"
+ ("control_after_generate" if name == "seed_control_candidate" else name)
.replace("~", "~0")
.replace("/", "~1"),
named_value=n["widgets_values_named"][
"control_after_generate" if name == "seed_control_candidate" else name
],
input_pointer=f"{ptr}/inputs/{inp}"
if inp is not None
else "无可靠独立输入映射:前端控制辅助",
input_name=n["inputs"][inp]["name"] if inp is not None else None,
type=n["inputs"][inp]["type"] if inp is not None else "保存参考",
role="frontend_reference_only"
if aux
else "boundary_saved_cache"
if boundary
else "linked_saved_cache"
if linked
else "saved_reference",
schema_default=default,
limits=limits,
unit=unit,
effect=display_effect,
evidence=refs[nid],
execution_note=(
"仅静态参考;所有中英文提示/指南均作数据,不"
"执行指令、构造prompt、调用LLM/SD"
"K/模型/GPU/媒体/随机/恢复/表达式/"
"缓存清理。转换执行资格不变。"
),
)
)
for (nid, name), (default, limits) in schemas.items():
flow.append(
(
f"节点{nid}准确schema {name}:default={default};"
f"{limits}。仅接口参考,不认证运行恢复。"
)
)
for pre, ptr, graph in scopes:
flow.extend(
(
(pre or "root") + " 物理边 " + json.dumps(e, ensure_ascii=False)
for e in graph["links"]
)
)
boundaries = [
dict(
host_node_id=pre,
definition_id=graph["id"],
definition_widgets=graph["widgets"],
proxy_widgets_present="proxyWidgets"
in next(n for n in g["nodes"] if str(n["id"]) == pre),
inputs=graph["inputs"],
outputs=graph["outputs"],
links=graph["links"],
notice="当前原件缓存、输入、输出和边界记录分别保留;无proxyWidgets不认证宿主恢复",
)
for pre, ptr, graph in scopes[1:]
]
flow += ["根附加保存属性 " + json.dumps(g["extra"], ensure_ascii=False)]
flow += prose["steps"]
flow += ["注释" + n["node_id"] + " 中文核对:" + n["meaning"] for n in comments]
overview = json.loads((OUT / "prose.json").read_bytes())["overview"]
assert len(fields) == 122 and len(comments) == 3
assert all("widgets_values_named" in n for _, _, _, n in nodes if n.get("widgets_values"))
return dict(
source_path=PATHS[index],
source_sha1=hashlib.sha1(raw).hexdigest(),
source_sha256=hashlib.sha256(raw).hexdigest(),
canonical_sha256=hashlib.sha256(canonical(g)).hexdigest(),
notice=(
"仅固定参考:当前Canny链与未接出的四类控制分支分列;704 mode4未接。"
"准确版本逐节点核准,缺类不借后版;目标环境、宿主恢复与真实效果未核,资格不变。"
),
user_overview=overview,
versions=[
(f"{e['id']} {e['tag']} commit {e['commit']} tree {e['tree']};许可{e['license_file']}")
for e in {e["id"]: e for e in manifest}.values()
]
+ [
(
"frontend1.53.6根许可与同树vendored LiteGraph MIT独立列,"
"LiteGraph源文件绑定其独立LICENSE,不以根许可替代。"
),
"旧104块5655位置/180注释冻结;新增122位置/三标准Note,总105图5777位置/183注释仅参考。local_file以docs/hel-892/qwen21-control-document-evidence为基准。",
],
counts=dict(
saved_fields=122,
root_saved_fields=53,
internal_saved_fields=69,
linked_saved_fields=sum(f["role"] == "linked_saved_cache" for f in fields),
boundary_saved_fields=sum(f["role"] == "boundary_saved_cache" for f in fields),
frontend_only=sum(f["role"] == "frontend_reference_only" for f in fields),
source_nodes=42,
root_nodes=17,
internal_nodes=25,
physical_edges=105,
source_notes=3,
saved_objects=1,
history_objects=2,
final_scalars=0,
final_prompt_constructed=False,
),
node_bindings=bindings,
fields=fields,
sources=sources,
comments=comments,
flow=flow,
flow_evidence=list(range(len(sources))),
zero_saved_nodes=empty,
boundaries=boundaries,
steps=[overview] + json.loads((OUT / "prose.json").read_bytes())["steps"],
)