Nodes/ComfyUI-ZML-Image/ZML_解析LoRA元数据
ComfyUI Node

ZML_解析LoRA元数据

Auto-fetch a LoRA's preview, trigger words, and writeup

By zml-w·Created about a year ago·Updated 2 months ago· 218
ZML_解析LoRA元数据
    • 图像
    • txt
    • log
    • 解析
    • help
    lora_名称
    保存首张图像false
    保存触发词为txtfalse
    保存介绍为logfalse

    Every ZML LoRA loader's txt/preview features depend on a convention: for each LoRA, there should be a same-named .png, .txt (trigger words), and .log (description) sitting in a zml subfolder next to it. Setting that up by hand is the most tedious chore in the whole pack. ZmlLoraMetadataParser (ZML_解析LoRA元数据) automates it: pick a LoRA, check the boxes, run, and it downloads the preview image, trigger words, and description from Civitai and drops them into place.

    How it works, in three stages. First it computes a SHA256 hash of the LoRA file and queries Civitai's API by hash - the same matching Civitai uses to identify uploads. If it finds a match, three optional flags control what gets saved: 保存首张图像 (save the first preview image), 保存触发词为txt (write trainedWords to the .txt), 保存介绍为log (write the model description and version info to the .log). Everything lands in models/loras/<something>/zml/ next to the LoRA. Second, independent of Civitai, it reads the LoRA's embedded training metadata (__metadata__ in the safetensors) and reports algorithm, learning rate, optimizer. Third, it loads whatever already exists in the zml folder as outputs.

    The outputs are the payoff: 图像 (the preview, or a black placeholder if none), txt (trigger words), log (description), 解析 (a human-readable dump of everything - Civitai model name, creator, base model, trigger words, training details, raw metadata), and help (a built-in instruction string). The README notes it also handles Wan LoRAs by saving MP4 + first frame where applicable.

    This is genuinely one of the pack's best ideas, and it's also where the pack's community norms show: the ZML "强力LoRA加载器" (power LoRA loader) does hover-preview over your LoRAs, and this parser is how you bootstrap the files that make those previews possible. If you manage a large LoRA library, running this once per new download turns every future workflow into "pick from a dropdown with a working thumbnail and the right trigger words already loaded."

    The caveats are real, though. It needs network access to Civitai, and hash matching only works for LoRAs that are actually uploaded there - private or locally-trained LoRAs return "can't fetch from Civitai" and you just get the embedded-metadata part. Downloads can fail silently-ish (there's a console log line). And note the Civitai terms: this is standard API use, but don't hammer it - run it once per LoRA, not in a loop.

    Security aside that applies to the whole pack but lands here: this node makes an external network call to Civitai on your behalf, and the pack itself is a large, open-source, actively-maintained project you're trusting with arbitrary Python. That's the normal calculus for ComfyUI custom nodes; just know what it does before the first run.

    Install:

    cd ComfyUI/custom_nodes
    git clone https://github.com/zml-w/ComfyUI-ZML-Image
    

    or via Manager, then restart. It's under ZML 图像 → lora加载器, requires requests (in the pack's requirements.txt) for the Civitai call. If you hand-maintain one LoRA's files, you don't need it; if you collect LoRAs like they're going out of style, it pays for itself on the first download.

    Categoryimage/ZML_图像/lora加载器

    Inputs (4)

    NameTypeDefaultDescription
    lora_名称COMBO0 options:
    保存首张图像optBOOLEANfalse
    保存触发词为txtoptBOOLEANfalse
    保存介绍为logoptBOOLEANfalse

    Outputs (5)

    NameTypeDescription
    图像IMAGE
    txtSTRING
    logSTRING
    解析STRING
    helpSTRING