Enhanced Model Metadata Reader
The ONNX Metadata Miner — and the One-Line Bug That Currently Breaks It
- STRING
EnhancedModelMetadataReader is the middle child of the three metadata nodes in Sinphaltimus/comfyui_fedcoms_node_pack, and it exists for one specific crowd: people with ONNX models. Think inswapper_128.onnx, the face-swap model everyone's downloaded, or the ONNX exports you find in third-party projects. The README's framing is honest - this node reads ONNX files by parsing the raw binary directly, with no onnx package and no heavy dependency. In theory that's neat. ONNX models carry readable metadata like author, description, license, and version, plus a mountain of ASCII strings: op names, layer names, even the PyTorch version they were exported from.
How it works (when it works)
extract_onnx_metadata() reads the whole file as bytes, pulls out runs of 4+ printable ASCII characters with a regex, then filters that text for metadata-ish keys (author, description, license, version, model_name). What it finds comes back as structured JSON, followed by the raw extracted strings truncated to the first 2000 characters. That's a genuinely useful autopsy for an ONNX file you know nothing about.
The catch: as shipped, it's broken
Here's where I have to be blunt. The current repo's metadata extraction line is:
metadata_found = {key: value for value in decoded_text if any(key in value.lower() for key in metadata_keys)}
That dict comprehension references key in the key-expression but only defines it inside the nested generator - a NameError on every single run. I reproduced it, and the author's own test log in the shipped example workflow shows the result: "error": "Failed to extract metadata: name 'key' is not defined", with empty raw text. The exception handler swallows the error, so you never see the strings the node was built to show. It's a one-line fix - the intended line looks like:
metadata_found = {k: v for v in decoded_text for k in metadata_keys if k in v.lower()}
Edit enhancedmodelmetadatareader.py in the custom_nodes folder and restart ComfyUI, and it does what the README promises. If you can't edit the file, skip this node and use the Advanced extractor instead.
Inputs, output, install
Same shape as its siblings. One required input, model_path - a STRING, full absolute path, pasted in (no file picker). One STRING output carrying a timestamped log, the JSON metadata, and the raw text. Wire the output into any string display node; the included example workflow routes it to a "Display String" node.
Install via ComfyUI Manager (search "comfyui_fedcoms_node_pack") or:
cd ComfyUI/custom_nodes
git clone https://github.com/Sinphaltimus/comfyui_fedcoms_node_pack
No models to download, no real dependency beyond what a stock ComfyUI already has. One honest warning: this node reads the entire binary, and the author's own test on a 528MB ONNX took about nine seconds - on multi-gigabyte models expect it to be slow, and be patient.
It's the most specialized of the three, and right now it's the most fragile. Worth installing only if you're up for that one-line patch and you actually work with ONNX files.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| model_path | STRING | Enter full model path here | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |