60 lines
8.0 KiB
Plaintext
60 lines
8.0 KiB
Plaintext
from pathlib import Path
|
|
import json
|
|
R=Path.cwd();D=R/'docs/hel-892/singleloop-document-evidence';F=R/'docs/hel-892/singleloop-reference';g=json.loads(next((R/'example_ComfyUI_workflows/5-数字人').glob('*单人for*')).read_bytes());S=R/'docs/hel-892/wantalk-document-evidence/build_definition.py';t=S.read_text();a=t.index('BINDINGS =');z=t.index('\n\ndef canonical',a)
|
|
files={'BasicScheduler':'comfy_extras/nodes_custom_sampler.py','KSamplerSelect':'comfy_extras/nodes_custom_sampler.py','CFGGuider':'comfy_extras/nodes_custom_sampler.py','RandomNoise':'comfy_extras/nodes_custom_sampler.py','SamplerCustomAdvanced':'comfy_extras/nodes_custom_sampler.py','AudioEncoderLoader':'comfy_extras/nodes_audio_encoder.py','AudioEncoderEncode':'comfy_extras/nodes_audio_encoder.py','ModelPatchLoader':'comfy_extras/nodes_model_patch.py','WanInfiniteTalkToVideo':'comfy_extras/nodes_wan.py','ImageFromBatch':'comfy_extras/nodes_images.py','LoadAudio':'comfy_extras/nodes_audio.py'}
|
|
layouts={'SetNode':['position_0'],'GetNode':['position_0'],'KSamplerSelect':['sampler_name'],'RandomNoise':['noise_seed','control_after_generate'],'CFGGuider':['cfg'],'BasicScheduler':['scheduler','steps','denoise'],'CLIPTextEncode':['text'],'WanInfiniteTalkToVideo':[f'position_{i}'for i in range(6)],'INTConstant':['value'],'FloatConstant':['value'],'CLIPVisionLoader':['clip_name'],'CLIPVisionEncode':['crop'],'ImageFromBatch':['batch_index','length'],'AudioCrop':['start_time','end_time'],'LoraLoaderModelOnly':['lora_name','strength_model'],'ModelPatchLoader':['name'],'AudioEncoderLoader':['audio_encoder_name'],'CLIPLoader':['clip_name','type','device'],'VAELoader':['vae_name'],'easy forLoopStart':['total'],'MathExpression|pysssss':['expression'],'Display Any (rgthree)':['position_0'],'LoadAudio':['audio','audioUI','upload'],'LoadImage':['image','upload'],'CR Prompt Text':['prompt'],'AudioSeparation':['chunk_fade_shape','chunk_length','chunk_overlap'],'UNETLoader':['unet_name','weight_dtype']}
|
|
bind={};ls={}
|
|
for n in g['nodes']:
|
|
typ=n['type'];nid=str(n['id']);p=n['properties'];ver=p.get('ver');cnr=p.get('cnr_id')
|
|
if typ in ['Note','MarkdownNote']:continue
|
|
if cnr=='comfy-core':key={'0.3.57':'core0357','0.3.67':'core0367','0.5.1':'core051','0.11.0':'core0110','0.15.0':'core0150','0.12.3':'core0123'}[ver];f=files.get(typ,'nodes.py');cl=typ
|
|
elif cnr=='comfyui-kjnodes':key='kjint'if ver.startswith('71578')else'kjfloat';f='nodes/nodes.py';cl=typ
|
|
elif cnr=='comfyui-easy-use':key='easy';f='py/nodes/logic.py';cl=typ.removeprefix('easy ')
|
|
elif cnr=='comfyui-custom-scripts':key='mathnew'if ver.startswith('26a')else'mathold';f='py/math_expression.py';cl='MathExpression'
|
|
elif cnr=='rgthree-comfy':key='rgthree';f='py/display_any.py';cl='RgthreeDisplayAny'
|
|
elif cnr=='audio-separation-nodes-comfyui':key='audio';f='src/crop.py'if typ=='AudioCrop'else'src/separation.py';cl=typ
|
|
elif cnr=='ComfyUI_Comfyroll_CustomNodes':key='cr';f='nodes/nodes_core.py';cl='CR_PromptText'
|
|
elif cnr=='comfyui-videohelpersuite':key='vhs';f='videohelpersuite/nodes.py';cl='VideoCombine'
|
|
else:assert typ in ['SetNode','GetNode'];key='unknown';f='';cl=typ
|
|
bind[nid]=(key,f,cl)
|
|
if isinstance(n['widgets_values'],list):ls[nid]=layouts.get(typ,[]);assert len(ls[nid])==len(n['widgets_values']),(nid,typ)
|
|
labels={'value':'常量原保存值','sampler_name':'采样器名称','noise_seed':'本阶段独立种子缓存','control_after_generate':'种子前端辅助保存','cfg':'CFG缓存原类型','scheduler':'调度器名称','steps':'步数缓存','denoise':'降噪缓存','text':'完整文本缓存','clip_name':'完整模型引用','crop':'视觉裁切策略','batch_index':'裁帧起点缓存(受625覆盖)','length':'裁帧批长度缓存','start_time':'裁音开始字符串','end_time':'裁音结束字符串','lora_name':'完整LoRA引用','strength_model':'LoRA模型强度','name':'完整patch引用','audio_encoder_name':'完整音频编码模型引用','type':'文本编码器类型','device':'加载设备策略','vae_name':'完整VAE引用','total':'循环总数缓存(受621覆盖)','expression':'完整原表达式(不求值)','audio':'原音频文件引用','audioUI':'原音频辅助null保存','upload':'原上传辅助保存','image':'原图像文件引用','prompt':'完整原中文文本','chunk_fade_shape':'分段淡化形状','chunk_length':'分段长度','chunk_overlap':'重叠参数原类型','unet_name':'完整扩散模型引用','weight_dtype':'权重类型策略','frame_rate':'帧率缓存(外线覆盖)','loop_count':'VHS额外循环次数','filename_prefix':'文件名前缀','format':'格式选择','pix_fmt':'像素格式','crf':'编码质量因子','save_metadata':'元数据保存条件','trim_to_audio':'按音轨裁切条件','pingpong':'往返排列条件','save_output':'输出目录保存条件','videopreview':'完整历史对象(仅文本)'}
|
|
t=t[:a]+'BINDINGS = '+repr(bind)+'\nLAYOUTS = '+repr(ls)+'\nLABELS = '+repr(labels)+t[z:]
|
|
t=t.replace('wantalk-reference','singleloop-reference').replace('Wan2.1_I2V_InfiniteTalk_提示词调度动作控制图生视频数字人(KJ版).json','Wan2.1_infinitetalk_音频驱动视频配音-单人for循环长视频(官流).json')
|
|
a=t.index(' if method is None:\n return {}')
|
|
t=t[:a]+''' if method is None:
|
|
method = next((m for m in class_node.body if isinstance(m, ast.FunctionDef) and m.name == "define_schema"), None)
|
|
if method is None:
|
|
return {}
|
|
schema = {}
|
|
for call in ast.walk(method):
|
|
if not isinstance(call, ast.Call) or not isinstance(call.func, ast.Attribute) or call.func.attr != "Input":
|
|
continue
|
|
if not call.args or not isinstance(call.args[0], ast.Constant) or not isinstance(call.args[0].value, str):
|
|
continue
|
|
default = next((ast.unparse(k.value) for k in call.keywords if k.arg == "default"), "无显式default;动态选项由准确代码/目标决定")
|
|
schema[call.args[0].value] = (default, ast.unparse(call))
|
|
return schema
|
|
'''+t[a+len(' if method is None:\n return {}\n'):]
|
|
a=t.index(' ei = next(');z=t.index(' schemas[nid] = schema',a)
|
|
chunk=t[a:z];chunk=' if key != "unknown":\n'+''.join(' '+line+'\n'for line in chunk.splitlines())+''' else:
|
|
schema, candidates, rs, cl = {}, [], [], None
|
|
source_id = "unknown-no-version"
|
|
''';t=t[:a]+chunk+t[z:]
|
|
t=t.replace('source_version=n["properties"]["ver"]','source_version=n["properties"].get("ver", "未知:只有aux名称,无版本")')
|
|
t=t.replace('scope="准确类/发布成员静态绑定;图中额外schema/端口冲突独立记录,不认证全图转换或目标安装"','scope="无版本Set/Get仅名称意图,准确实现/schema/默认/副作用/恢复未知" if key == "unknown" else "准确类或选定入口范围未匹配分列;不认证全图转换或目标安装"')
|
|
t=t.replace('if nid == "131" and name in','if nid in ["245", "246"] and name in')
|
|
a=t.index(' aux = (');z=t.index(' linked =',a)
|
|
t=t[:a]+''' aux = (
|
|
(nid in ["171", "229"] and name == "control_after_generate")
|
|
or (nid == "32" and name == "upload")
|
|
or (nid in ["245", "246"] and name == "videopreview")
|
|
or (nid == "255" and name == "position_0")
|
|
)
|
|
'''+t[z:]
|
|
t=t.replace('len(fields) == 118 and len(bindings) == 26 and len(comments) == 7 and len(empty) == 1','len(fields) == 129 and len(bindings) == 90 and len(comments) == 5 and len(empty) == 8')
|
|
t=t.replace('23准确类/发布成员实例、3具体未匹配实例','42准确类/发布成员实例、129与232两个准确入口未匹配、46个无版本Set/Get实例')
|
|
t=t.replace('source_nodes=33','source_nodes=95').replace('root_nodes=33','root_nodes=95').replace('physical_edges=29','physical_edges=90').replace('source_notes=7','source_notes=5').replace('saved_objects=1','saved_objects=2').replace('history_objects=1','history_objects=2')
|
|
(D/'build_definition.py').write_text(t)
|
|
print('Prepared explicit node bindings',len(bind),'non-alias',sum(v[0]!='unknown'for v in bind.values()))
|