"ControlNet source-bound Chinese editorial data; never execute upstream code." from __future__ import annotations import hashlib import json from pathlib import Path REPO = Path(__file__).resolve().parents[3] OUT = Path(__file__).resolve().parent PATH = ( "example_ComfyUI_workflows/0-基础处理:图像合并-音频分离-视频截取合并-图像视频放大/Control" "Net_aux_常用样例.json" ) def canonical(value): return json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode() def build(): raw = (REPO / PATH).read_bytes() source = json.loads(raw) refs, fields = [], [] def ref(directory, filename, start, end, claim): root = OUT.parent / directory item = next( s for s in json.loads((root / "sources.json").read_bytes())["sources"] if s["local_file"] == filename ) data = (root / filename).read_bytes() assert hashlib.sha256(data).hexdigest() == item["sha256"] assert 1 <= start <= end <= len(data.decode().splitlines()) refs.append( { **{k: item[k] for k in ("id", "commit", "file", "sha256", "url")}, "license": item.get("license", "沿用来源manifest许可"), "local_file": "../" + directory + "/" + filename, "lines": [start, end], "claim": claim, } ) return len(refs) - 1 def own(filename, start, end, claim): return ref(OUT.name, filename, start, end, claim) dispatch = ref( "controlnet-reference", "__init__.py", 25, 130, "导入失败影响动态注册;AIO选项排除、none分支、选中类schema默认分派与FUNCTION调用", ) common = ref( "controlnet-reference", "utils.py", 60, 120, ( "required image/optional顺序;resolution schema 512/64..16384/64;COM" "BO首项默认与逐图像公共调用" ), ) depth = ref( "controlnet-reference", "node_wrappers__depth_anything.py", 4, 25, "Depth schema、vitl14默认与from_pretrained/设备/common_annotator_call调用", ) depthreg = ref( "controlnet-reference", "node_wrappers__depth_anything.py", 48, 55, "DepthAnythingPreprocessor注册到具体类", ) depthimpl = own( "src__custom_controlnet_aux__depth_anything__transformers.py", 13, 80, "旧checkpoint名映射HF模型;先local_files_only尝试后pipeline回退;分辨率缩放与深度归一化", ) depthalias = own( "src__custom_controlnet_aux__depth_anything____init__.py", 1, 1, "DepthAnythingDetector导出到transformers实现", ) resize = own( "src__custom_controlnet_aux__util.py", 155, 173, "短边比例缩放/取整、pad64与remove_pad;不保证源resolution等于输出宽高", ) cannyaux = own( "node_wrappers__canny.py", 4, 29, "AIO Canny整数阈值100/200(0..255)、resolution与CannyDetector调用", ) cannyimpl = own( "src__custom_controlnet_aux__canny____init__.py", 7, 17, "AIO所选Canny实现经resize_image_with_pad调用cv2.Canny;不等于core kornia尺度", ) anyline = own( "node_wrappers__anyline.py", 22, 87, "AnyLine schema/默认、MTEED与标准线稿合成、形态小对象过滤;AIO传自身resolution覆盖1280默认", ) lineart = own( "node_wrappers__lineart.py", 4, 29, "写实线稿schema coarse首项disable、模型调用与注册" ) anime = own( "node_wrappers__lineart_anime.py", 4, 26, "动漫线稿schema、from_pretrained/公共调用与注册" ) standard = own( "node_wrappers__lineart_standard.py", 4, 26, "标准线稿guassian_sigma=6.0、intensity_threshold=8及调用/注册(原拼写保留)", ) dw = own( "node_wrappers__dwpose.py", 31, 107, "DW schema默认手/身体/面部enable与两个模型选择、实际调用/字典result", ) animal = own( "node_wrappers__dwpose.py", 109, 166, "AnimalPose schema默认与函数默认区别、模型路由、结果及注册", ) canny = ref( "serialization-evidence", "corev0.21.1__comfy_extras__nodes_canny.py", 9, 44, "core0.21.1 Canny schema浮点0.01..0.99、默认0.4/0.8与kornia输出处理", ) stitch = ref( "serialization-evidence", "corev0.17.0__comfy_extras__nodes_images.py", 253, 424, "ImageStitch schema与方向/批量补齐/匹配缩放/通道补齐/间隔/拼接条件", ) load = ref( "serialization-evidence", "corev0.21.1__nodes.py", 1678, 1754, "LoadImage动态输入文件列表、IMAGE/MASK出口、读取/校验;未执行", ) ref( "serialization-evidence", "corev0.21.1__nodes.py", 1609, 1679, "PreviewImage继承SaveImage:temp目录PNG和ui.images文件描述,非不落盘预览", ) restore = ref( "serialization-evidence", "src__lib__litegraph__src__LGraphNode.ts", 862, 922, "configure按控件位置恢复;serialize按下标保存;不按UI input数组猜字段", ) order = ref( "serialization-evidence", "src__services__litegraphService.ts", 143, 230, "schema有序输入与控件构造", ) upload = ref( "serialization-evidence", "src__extensions__core__uploadImage.ts", 12, 53, "image_upload附加upload输入", ) uploadwidget = ref( "serialization-evidence", ("src__renderer__extensions__vueNodes__widgets__composables__useImageUploadWidget.ts"), 90, 104, "upload按钮初值image,options.serialize=false,非后端image字段", ) execution = ref( "serialization-evidence", "src__utils__executionUtil.ts", 76, 150, "执行剔除options.serialize=false、沿Reroute解析连线并覆盖同名输入", ) ref( "serialization-evidence", "src__extensions__core__rerouteNode.ts", 26, 47, "Reroute纯前端虚拟节点,无执行算法", ) def field( node, offset, name, label, typ, unit, limits, effect, default, evidence, role="scalar" ): i = next(i for i, n in enumerate(source["nodes"]) if n["id"] == node) n = source["nodes"][i] v = n["widgets_values"][offset] fields.append( dict( node_id=str(node), class_type=n["type"], field=name, label=label, type=typ, value=v, json_type=type(v).__name__, pointer=f"/nodes/{i}/widgets_values/{offset}", unit=unit, limits=limits, effect=effect, schema_default=default, evidence=[*evidence, restore, order, execution], role=role, execution_note="仅前端上传按钮保存状态;options.serialize=false,执行时剔除,不能当第二个素材参数。" if role == "frontend" else "固定参考恢复后的标量;源图原值保留,目标UE改写/环境/实跑未知。", ) ) def resolution(node, evidence): field( node, 1, "resolution", "处理分辨率", "INT", "像素尺度(非实际输出尺寸)", "schema 64..16384、步进64、默认512;公共调用仅对int且>=64直接采用,否则回退512。", ( "传给选中处理器的detect_resolution。512/1024是源值,非推荐值;Depth/Canny固定实现按短边比例缩" "放取整并补边/去边;其它处理器深层尺寸行为未核实,不承诺输出宽高或细节/识别精度。" ), ( "AIO/Depth schema 512;选中AnyLine自身schema1280被AIO传入值覆盖。" if node == 18 else "AIO/Depth schema 512;源值与schema默认分开。" ), [common, resize, *evidence], ) field( 4, 0, "ckpt_name", "深度模型选择", "COMBO / STRING", "不适用", "固定列表vitl14/vitb14/vits14三个.pth名称;目标模型/缓存/列表可用性未知。", ( "显式Depth4选择vitl14。固定实现映射LiheYoung/depth-anything-large-hf,先尝试本地缓存" ",异常回退pipeline可能联网取模型;本轮仅静态读取,不查目录/加载/下载。深度相对归一化不代表物理距离或识别精度。" ), "schema首项depth_anything_vitl14.pth;函数同名默认。", [depth, depthreg, depthalias, depthimpl, common], ) resolution(4, [depth, depthimpl]) branches = { 1: ( "AIO深度分支", [depth, depthimpl, depthalias], ( "选DepthAnythingPreprocessor,AIO取schema ckpt首项vitl14并传512;与显式Depth" "4静态参数可对应,但未证明目标扩展/模型/结果等价。" ), ), 12: ( "AIO边缘分支", [cannyaux, cannyimpl], ( "选CannyEdgePreprocessor,AIO补整数low=100/high=200,传1024,经cv2.Canny;与" "core10的kornia浮点0.4/0.8不是同尺度,不换算为相同阈值。" ), ), 18: ( "AnyLine线稿分支", [anyline], ( "选AnyLineArtPreprocessor_aux,默认merge_with_lineart=lineart_standar" "d、lower/upper=0/1、object_min_size=36/connectivity=1;MTEED与标准线稿合成" ",内部sigma=2/intensity=3,AIO1024覆盖其schema1280。模型和skimage依赖未知。" ), ), 19: ( "写实线稿分支", [lineart], ( "选LineArtPreprocessor,AIO补coarse=disable并传1024;调用LineartDetector." "from_pretrained,不保证真实画面线条质量。" ), ), 20: ( "动漫线稿分支", [anime], "选AnimeLineArtPreprocessor,传1024至LineartAnimeDetector公共调用;权重及真实适用性未知。", ), 21: ( "标准线稿分支", [standard], ( "选LineartStandardPreprocessor,AIO补guassian_sigma=6.0、intensity_th" "reshold=8并传1024;与AnyLine内部2/3设置不同;深层算法效果未扩查。" ), ), 33: ( "DW人物姿态分支", [dw], ( "选DWPreprocessor,AIO补hand/body/face=enable、bbox=yolox_l.onnx、pose" "=dw-ll_ucoco_384_bs5.torchscript.pt、scale_stick=disable并传1024;sc" "hema pose默认与函数默认不同,AIO用schema。结果字典含IMAGE/POSE_KEYPOINT与openpose_" "json;AIO本身声明仅IMAGE,本图图像接Preview36;不保证识别精度或设备后端可用。" ), ), 34: ( "Animal动物姿态分支", [animal], ( "选AnimalPosePreprocessor,AIO补bbox=yolox_l.torchscript.pt、pose=rtm" "pose-m_ap10k_256_bs5.torchscript.pt并传1024;schema默认与函数onnx默认分开,AI" "O用schema。38单独供图,结果图像接Preview37;AIO本身声明仅IMAGE,关键点不构成本图文件产物。" ), ), } for node, (label, evidence, effect) in branches.items(): field( node, 0, "preprocessor", label + "选择器", "动态COMBO / STRING", "不适用", "注册成功的AUX_NODE_MAPPINGS键剔除不支持类后构成动态选项;源保存名称不证明目标已注册。", effect + ( " AIO按选中类schema填默认、image/resolution显式传入再调FUNCTION;" "none直接返回输入。本图均非none。" ), "AIO schema none;本图源选择分别保留。", [dispatch, common, *evidence], ) resolution(node, [dispatch, *evidence]) for off, name, label, default in [ (0, "low_threshold", "核心Canny低阈值", "0.4"), (1, "high_threshold", "核心Canny高阈值", "0.8"), ]: field( 10, off, name, label, "FLOAT", "无额外物理单位;kornia阈值尺度", "schema 0.01..0.99、步进0.01;不与AIO整数0..255混用。", ( "将输入转设备float32并movedim送kornia.filters.canny,取边缘输出复制三通道。改变阈值影响该调用条" "件,具体画面/边缘细节未实测。" ), default, [canny], ) for node in [28, 29, 30]: for off, name, label, typ, unit, limits, effect, default in [ ( 0, "direction", "拼接方向", "COMBO / STRING", "不适用", "right/down/left/up", "image2相对image1位置;28/29为right构成两行,30为down将第二行置下。", "right", ), ( 1, "match_image_size", "匹配拼接尺寸", "BOOLEAN", "不适用", "true/false", ( "true时水平拼接把image2等比缩放至image1高度,垂直匹配宽度,lanczos且禁裁切;false对非拼接维居中补齐。" "批量不足重复末张、通道不足补1;不保证真实产物尺寸。" ), "true", ), ( 2, "spacing_width", "拼接间隔", "INT", "像素", "0..1024、步进2", "源2作为拼接方向的间隔宽度;缺image2直接原样返回image1,不创建比较图。", "0", ), ( 3, "spacing_color", "间隔颜色", "COMBO / STRING", "不适用", "white/black/red/green/blue", "源white为间隔填充白色;非匹配尺寸时也影响补齐颜色规则,不改变输入素材身份。", "white", ), ]: field(node, off, name, label, typ, unit, limits, effect, default, [stitch]) for node in [2, 38]: field( node, 0, "image", "输入图像引用", "动态COMBO / STRING", "不适用", "按input目录文件及图像类型过滤的动态列表;引用不证明文件存在、可读或主体合适。", ( "2供深度/边缘/四线稿/DW;38独立供AnimalPose。未来获准环境核对2中需观察的轮廓/人物、38中动物主体是否清晰,不" "能凭文件名确认内容。LoadImage返回IMAGE与MASK,本图MASK均未接。" ), "动态文件列表,无固定通用文件默认。", [load, upload], ) field( node, 1, "upload", "上传按钮保存状态", "前端按钮 / STRING", "不适用", "源字符串image,非运行枚举或第二素材。", "附加upload按钮初值image;保存状态与image引用分开,不能拼成素材路径或执行字段。", "按钮初值image。", [upload, uploadwidget], role="frontend", ) # Expand physical paths without executing any processing algorithm. nodes = {n["id"]: n for n in source["nodes"]} links = {e[0]: (i, e) for i, e in enumerate(source["links"])} endpoints = [] for n in source["nodes"]: if n["type"] == "Reroute": continue for inp in n.get("inputs", []): lid = inp.get("link") if lid is None: continue chain = [] while True: i, e = links[lid] chain.append(dict(pointer=f"/links/{i}", edge=e)) upstream = nodes[e[1]] if upstream["type"] != "Reroute": break lid = upstream["inputs"][0]["link"] endpoints.append( dict( node_id=str(n["id"]), field=inp["name"], endpoint=[str(e[1]), e[2]], source_chain=chain, ) ) assert len(endpoints) == 23 and sum(len(e["source_chain"]) > 1 for e in endpoints) == 9 api_raw = (OUT.parent / "supplied-api/01.api.json").read_bytes() api = json.loads(api_raw) from calliope.comfyui.serialization_reference import AUX_PROFILE from calliope.comfyui.ui2api import convert_reference candidate = convert_reference(source, AUX_PROFILE).prompt assert candidate and len(candidate) == len(api) == 22 assert all(candidate[k]["class_type"] == api[k]["class_type"] for k in api) binding = next( c for c in json.loads((OUT.parent / "supplied-api/manifest.json").read_bytes())["cases"] if c["id"] == "01" ) assert binding["source_sha256"] == hashlib.sha256(raw).hexdigest() assert binding["export_sha256"] == hashlib.sha256(api_raw).hexdigest() assert all( candidate[k]["inputs"] == api[k]["inputs"] and canonical(candidate[k]["inputs"]) == canonical(api[k]["inputs"]) for k in api ) assert all(api[e["node_id"]]["inputs"][e["field"]] == e["endpoint"] for e in endpoints) titles = [ dict(node_id=k, reference=candidate[k].get("_meta"), api=api[k].get("_meta")) for k in api if candidate[k].get("_meta") != api[k].get("_meta") ] assert len(titles) == 13 flow = [ ( "用途:同一输入2对比深度、两种边缘、四种线稿与DW人物姿态,输入38单独观察AnimalPose;本轮不处理图像。26源节点/2" "7物理边,4虚拟Reroute无保存控件;22实体参考候选含34标量+23端点(9经转接),不是57个源保存值。" ), ( "两素材引用独立保留:2=comfyui-airport-editorial_00001_.png,38=177208682157" "3.png;可达性、图像尺寸/内容与真实主体未知,两个MASK出口均未接。" ), ( "深度:2槽0→Reroute32→4.image与1.image,4→Preview5,1→Preview3;4显式vitl14" "/512,1选DepthAnything/512由分派填同名schema默认;静态参数对应不保证执行或效果相同。" ), ( "边缘:2槽0→Reroute31→Canny10与AIO12,10→Preview11、12→Preview13;core0.4" "/0.8与AIO内部100/200分属不同实现与尺度,不能换算/承诺对照效果。" ), ( "线稿:2槽0→Reroute24→AIO18/19/20/21;18/19→ImageStitch28(right),20/21" "→29(right),28/29→30(down)→Preview22;这是一张2×2线稿比较排版,非已生成四张等大图片。" ), ( "姿态:2槽0→Reroute35→AIO33→Preview36;38槽0→AIO34→Preview37。人物/动物支路各自保" "留输入、选择与结果路径;所选类的POSE_KEYPOINT并非本图AIO声明出口,不视为下载产物。" ), ( "七预览3/5/11/13/22/36/37均无保存控件:分别对应AIO深度/显式深度/core边缘/AIO边缘/四线稿拼接/DW" "/Animal。core0.21.1 Preview继承保存逻辑,将PNG落temp目录,返回ui.images含filenam" "e/subfolder/type=temp;不表示永久导出或实际history成功。" ), "case01配套01.api.json SHA256 " + hashlib.sha256(api_raw).hexdigest() + ( ":原始API与当前固定候选22实体、57输入(34标量/23端点)逐项及JSON类型一致,9经转接链最终端点一致;完整JSON仍" "13处标题元数据差异。历史配套不是目标安装/运行等价证明,不改294原配套参数、companion_unverified/env" "ironment_unchecked/空映射/停用资格。" ), ] for e in endpoints: flow.append( "逐跳依据:" + e["node_id"] + "." + e["field"] + " ← " + json.dumps(e["endpoint"], ensure_ascii=False) + ";" + " ← ".join( x["pointer"] + "=" + json.dumps(x["edge"], ensure_ascii=False) for x in e["source_chain"] ) ) fields.sort(key=lambda f: tuple(int(f["pointer"].split("/")[i]) for i in (2, 4))) assert len(fields) == 36 return dict( notice="固定版本参考说明:节点按源声明分别核对固定提交;前端未声明,1.37.11仅显式假设;aux发布包与提交绑定、UE与目标环境未知", source_path=PATH, source_sha1=hashlib.sha1(raw).hexdigest(), source_sha256=hashlib.sha256(raw).hexdigest(), canonical_sha256=hashlib.sha256(canonical(source)).hexdigest(), versions=[ ( "AIO/Depth声明comfyui_controlnet_aux1.1.5,仅参考e8b689a513c3e6b63edc44" "066560ca5919c0576e;pyproject变更不证明发布包/registry→commit或目标安装绑定。" ), ( "LoadImage/Canny/Preview声明core0.21.1=26515acd23fa291a8f5ab53c5997" "258598de0701;ImageStitch声明0.17.0=63d1bbdb407c69370d407ce5ced6ca3" "f917528a8。" ), ( "前端未声明,仅参考1.37.11=4bf6a1960028cc5cda57d48f9fb01a74dfaade43;UE7.8/" "7.7记录不证明序列化影响已验证,动态选项/依赖/权重/缓存/设备/真实history未知。" ), ], counts=dict( saved_fields=36, final_scalars=34, linked_saved_fields=0, frontend_only=2, physical_edges=27, ), fields=fields, sources=refs, flow=flow, flow_evidence=list(range(len(refs))), resolved_endpoints=endpoints, companion_difference=dict( historical_binding={ k: binding[k] for k in ( "id", "attachment_id", "received_at", "source_comment_id", "exported_at", "frontend_version", "node_versions", ) }, export_file="01.api.json", export_sha256=hashlib.sha256(api_raw).hexdigest(), scalar_matches=34, endpoint_matches=23, rerouted_endpoints=9, title_differences=titles, source_export_equivalence_verified=False, ), steps=[ "未来获得实跑授权后先核对真实前端/插件版本、动态选项、权重及两张素材;本轮只读固定源码,不查目标目录、不加载/下载。", "核对输入2在32/31/24/35四个转接分配到九个处理分支,输入38仅供Animal;保持两引用和未接MASK,不合并换图。", "分开核对4与1的checkpoint/选择器和512、10浮点阈值与12整数默认和1024,再观察对应5/3/11/13预览;不将参数相近视为效果等同。", ( "逐路核对18 AnyLine、19写实、20动漫、21标准线稿选择与1024;" "检查18/19→28右拼、20/21→29右拼、2" "8/29→30下拼→22的2×2布局及2像素白间隔,尺寸/画面内容仍待实际核对。" ), "分别检查33人物/34动物支路及36/37预览;检查七Preview临时PNG和实际history后才讨论产物,不能将说明展示视为已运行。", "保留API配套层与源图层独立、标题差异与逐跳链可回读;当前说明未定稿、依赖未检查、实跑未验证、全停用,不新增转换资格。", ], ) def main(): target = REPO / "calliope-backend/src/calliope/comfyui/source_reviews.json" reviews = json.loads(target.read_bytes()) block = build() assert reviews[PATH]["source_sha"] == block["source_sha1"] reviews[PATH]["fixed_version_document"] = block target.write_text(json.dumps(reviews, ensure_ascii=False, indent=2) + "\n") (OUT / "definition.json").write_text(json.dumps(block, ensure_ascii=False, indent=2) + "\n") print(hashlib.sha256(canonical(block)).hexdigest()) if __name__ == "__main__": main()