Skip to content

tricksterzero/comfyui-model-usage-counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ComfyUI Model Usage Counter

English | 日本語

A ComfyUI custom node that automatically records how many times each model is used and when it was last used. Just drop it on your graph and the counts grow with every generation.

Handy for answering questions like "which checkpoint have I been using lately?" or "which models am I no longer using?"

Features

  • Just drop it in — place one node on your graph; no wiring (input connections) needed.
  • Automatic counting — records the models actually used on every generation.
  • Per-type totals — counts checkpoints, diffusion models (unet), and LoRAs separately.
  • Last-used timestamp — see when each model was last used.
  • Shown on the node — the current totals are displayed on the node after each generation.
  • Saved as JSON — data is written to model_usage.json for use by other tools.
  • No extra dependencies — standard library only.

Installation

Clone into your custom_nodes directory and restart ComfyUI:

cd ComfyUI/custom_nodes
git clone https://github.com/tricksterzero/comfyui-model-usage-counter.git

Or install via ComfyUI-Manager ("Install via Git URL").

Usage

  1. Add Model Usage Counter from the utils/stats category (node search or menu).
  2. Place it anywhere on your graph (it doesn't need to be connected to anything).
  3. Generate as usual (Queue Prompt).
  4. The models you used are written to model_usage.json, and the current totals are shown on the node.

The display language follows your ComfyUI locale (Comfy.Locale): English by default, and Japanese when the locale is set to Japanese. The node displays something like this (it appears after one generation):

[checkpoint]
  count  last used               elapsed  model
     12  2026-06-02 00:47:48    just now  someCheckpoint.safetensors
      4  2026-05-31 00:47:58  2 days ago  olderCheckpoint.safetensors
[lora]
  count  last used               elapsed  model
     18  2026-06-02 00:07:58  40 min ago  detailTweaker.safetensors
      5  2026-05-29 00:47:58  4 days ago  char/someCharacter.safetensors
[unet]
  count  last used             elapsed  model
     30  2026-06-01 22:47:58  2 hr ago  someDiffusionModel.safetensors
      8  2026-03-24 00:47:58  2 mo ago  anotherDiffusionModel.safetensors

Each bucket starts with a header row — count / last used / elapsed / model. Entries are ordered by most recently used first, and columns are width-aware (full-width-safe) aligned. Timestamps use the timezone of the machine running ComfyUI — for a typical local install this is your own local time.

Recorded data

Data is saved to model_usage.json. It lives in a model-usage-counter/ folder inside ComfyUI's user directory — not inside this repository — so it survives updates and reinstalls. (The output directory is deliberately avoided since it can be served over HTTP.)

{
  "checkpoint": {
    "someCheckpoint.safetensors": { "count": 12, "last_used": "2026-06-01T14:30:00+09:00" }
  },
  "unet": {
    "someDiffusionModel.safetensors": { "count": 30, "last_used": "2026-06-01T15:02:11+09:00" }
  },
  "lora": {
    "detailTweaker.safetensors": { "count": 18, "last_used": "2026-06-01T17:29:30+09:00" }
  }
}
  • count … number of times the model was used
  • last_used … when it was last used (the ComfyUI server machine's local time, ISO 8601 with UTC offset)

Tracked models

These loaders are currently counted:

Loader bucket
CheckpointLoaderSimple checkpoint
UNETLoader unet
LoraLoader (Load LoRA) lora
LoraLoaderModelOnly (Load LoRA) lora
LoraLoader|pysssss (Custom-Scripts) lora
Power Lora Loader (rgthree) lora
Lora Loader (LoraManager) lora

For loaders that bundle multiple LoRAs (rgthree Power Lora Loader, Lora Loader (LoraManager)), only the enabled/active entries are counted, each recorded separately. All LoRAs are grouped together under the lora bucket regardless of which loader they came from. To track other simple loaders, add a line to LOADER_KEYS in __init__.py (see "How it works" below).

Supported extensions

Built-in ComfyUI loaders (CheckpointLoaderSimple, UNETLoader, LoraLoader, LoraLoaderModelOnly) work out of the box. The following third-party extensions are also supported — install them from their repositories or via ComfyUI-Manager:

Power Lora Loader — counts each enabled (on) LoRA.

Lora Loader (LoraLoader|pysssss) — counts the loaded LoRA.

Lora Loader (LoraManager) — counts each active LoRA.

Limitations

  • With batch_count > 1, the count increases by the number of images generated (usage is counted per image, not per workflow run).
  • Placing multiple Model Usage Counter nodes in one graph still counts only once (totals are never inflated by node count).
  • Duplicate loaders within a single graph are each counted, reflecting actual usage.

How it works

Technical details (click to expand)

Built on ComfyUI's V3 node schema (comfy_api.latest).

This is an output node with no output ports. On every generation it:

  1. Reads the full prompt graph (via the hidden prompt input that output nodes receive automatically).
  2. Finds the loader nodes that were actually used and extracts their model names.
  3. Increments a per-model counter, records the last-used timestamp, and writes them to model_usage.json.
  4. Returns the totals as text, which the bundled JS extension renders on the node.

Because it has no outputs, it never triggers recomputation of downstream nodes (KSampler, etc.). A fingerprint_inputs() returning the current time forces the node to run on every generation, so counts increment even when the same model is reused.

The on-node display works by returning a ui dict from execute() that carries the summary pre-formatted per language (text = English default, plus text_en / text_ja), delivered in the executed event. The bundled JS extension (js/model_usage_counter.js, served through WEB_DIRECTORY) reads the ComfyUI locale (Comfy.Locale), picks the matching language, and renders it into a read-only multiline widget. Timestamps are formatted on the backend using the ComfyUI server machine's timezone.

Simple loaders are defined in LOADER_KEYS in __init__.py. Add a line in the form class_type -> (model name key, bucket, folder_paths folder) to track more. The third item is the folder_paths category used to verify the model exists: only names present in folder_paths.get_filename_list(...) are recorded, so arbitrary strings in a submitted prompt can't bloat model_usage.json. Confirm the class_type and inputs key from the prompt metadata of an actual output PNG, and the folder name from the loader's INPUT_TYPES.

Loaders that bundle multiple models in a non-trivial input structure are handled by dedicated branches in extract_models():

  • rgthree Power Lora Loaderinputs hold many lora_N entries of the form {"on": bool, "lora": "name", "strength": float, ...} (_extract_power_loras).
  • Lora Loader (LoraManager)inputs["loras"] holds a list ({"__value__": [...]} or a plain list) of {"name", "active", "strength", ...}; active entries are resolved to the real folder_paths filename, since the stored name may omit the extension or subfolder (_extract_loramanager_loras + _resolve_lora_name).

Adding another such loader means writing a similar branch.

Requirements

  • A ComfyUI version that supports the V3 node schema (comfy_api.latest).
  • No extra Python dependencies (standard library only).

License

MIT

About

A minimal ComfyUI custom node that counts how many times each model is used, incremented on every generation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors