Nodes/ClipVision_Tools/Folder Scores
ComfyUI Node

Folder Scores

Rank whole folders instead of single images

By MoonMoon82·Created 11 months ago·Updated 10 months ago· 10
Folder Scores
  • results
  • folderstats
  • filterstring
offset_index0
folder_count1
matchfirst
weighted_threshold-1.000
min_folder_level0
max_folder_level100

Folder Scores is the zoom-out node: it takes the per-image scores from a search and rolls them up to the folder level, answering "which folder in my collection is my query most like?" Instead of "these 500 images are similar," you get "these 5 folders are similar, and here's how each one scored." For anyone organizing a large reference library by subject, this is the report card at the end of a search.

It works on the folder structure of your database's stored paths. Every result contributes a weighted score to each ancestor folder it lives under (down to a configurable depth), each folder gets a representative score computed as the most common score bin in its distribution, and the folders are sorted like any other result set.

The inputs that matter

  • results - a SRESULTS output from Image Searcher.
  • folder_count - how many folders to report. Default 1.
  • offset_index - where to start in the ranked folder list, so you can page through "top 5, next 5…" by bumping it.
  • match - first ranks highest-scoring folders first, last reverses it.
  • weighted_threshold - a similarity floor (default -1 = off) used in the per-image weighting, (1 + score − threshold) * score. Raise it to penalize low-similarity images more harshly inside a folder's score.
  • min_folder_level / max_folder_level - the folder-depth window to include. min 0 includes the top level; raise min_folder_level to ignore shallow folders and only score deeper subfolders.

The outputs

Two strings, and the second one is the sneaky good part:

  • folderstats - formatted text listing each folder and its representative score, ready for a text/console display node.
  • filterstring - a list of foldername* wildcard patterns for exactly those folders. Paste it into EditResults or EditDB with method "filter" and your search results collapse down to just the top folders. That's the natural end of this node: rank folders, then filter to the winners.

Installing it

Standard pack install:

cd ComfyUI/custom_nodes
git clone https://github.com/MoonMoon82/ClipVision_Tools
cd ClipVision_Tools
python -m pip install -r requirements.txt

Or ComfyUI Manager → "ClipVision_Tools" → restart. Deps: orjson, pillow-heif.

Gotchas

  • It's as good as your folder structure. If your collection is one flat dump, every image lands in the same folder and the report is one line. Folder Scores is built for organized trees.
  • The representative score is a mode, not an average (the code bins scores into 512 buckets and takes the most common one). That's deliberate - it resists a couple of outliers - but it means the number can differ from your intuition about "average similarity."
  • folderstats and filterstring must be displayed or consumed by something - they're plain strings and the node won't show them itself.
  • Output is text, not a graph: to act on the ranking you go through EditResults, which is a manual step but a clean one.

If your mental model of the collection is "folders of concepts," this node is the fastest way to find the right folder for a given query. It's the quiet workhorse of the pack and it's far more useful than its zero-impressions listing suggests.

CategoryClipVisionTools

Inputs (7)

NameTypeDefaultDescription
resultsSRESULTS
offset_indexINT00–18446744073709550000first result to show
folder_countINT11–18446744073709550000Maximum amount of folders to show
matchCOMBOfirstSort order of folders to show
weighted_thresholdFLOAT-1.000-1–1Similarity threshold for weighted scoring each image
min_folder_levelINT00–18446744073709550000minimum folder depth to include in scoring
max_folder_levelINT1000–18446744073709550000maximum folder depth to include in scoring

Outputs (2)

NameTypeDescription
folderstatsSTRING
filterstringSTRING