Edit Embeddings Database
Prune and re-point an embedding database before you search it
- img_db
- IMG_DB
Edit Embeddings Database is EditResults' bigger sibling, applied one level earlier in the pipeline. Where EditResults filters the results of a search, EditDB filters the database itself before you ever search it. Same three methods, same wildcard matching, but the input is a LoadDB object and the output is a new, edited database.
Why would you bother? Three reasons, in rough order of usefulness:
- Shrink before searching. A 100,000-image database is fine to search, but if you only care about results from
*beach*folders, pruning the DB down first makes every downstream step faster and cleaner - and scores stay relative to what's left. - Re-point a moved folder. Same "replace" trick as EditResults: images moved, paths now 404, so rewrite the old path prefix to the new location in the DB without regenerating any embeddings.
- Segment a shared DB. One big collection, multiple focused searches against different subsets. EditDB gives each branch its own trimmed copy.
How it works
The inputs mirror EditResults: img_db (the LoadDB output), method (exclude to drop matches, filter to keep only matches, replace to rewrite matched path text with replace_text), and edit_text for the wildcard pattern (* matches any run of characters, fnmatch style). The node walks every entry in the loaded DB, applies the rule to each stored filename, and hands back a fresh IMG_DB output you can wire into Image Searcher or chain into another EditDB.
One important detail: the edit is in-memory only. Your new_img_db.json on disk is untouched; what you get back is a filtered view living in the current graph. If you want the trimmed database persisted, regenerate it (or write your own export) - this node won't do it for you.
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 via ComfyUI Manager ("ClipVision_Tools"). Restart after. Deps are orjson and pillow-heif only.
Gotchas
- It edits paths, not content. The embeddings stay whatever they were. Filtering out a folder doesn't improve how the remaining images are represented - it just removes them from consideration.
- Keep the model rule in mind: if you're chaining multiple LoadDBs or edited DBs together, they all have to come from the same CLIP vision model or the search is meaningless.
- The replace pattern strips the
*you put in the match:edit_textoldpath*withreplace_text/newpath/rewrites the matched prefix. Check one result before trusting the whole DB. - Wildcards, not regex.
*and?only. Don't bring your regex muscle memory.
It's a small, unglamorous node, but it's the difference between "search this 100k collection" and "search the 2k images that are actually relevant to this job." For anyone building a reference-library workflow, that's the node you'll quietly reach for every day.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| img_db | LoadDB | — | |
| method | COMBO | exclude | Method to edit results |
| edit_text | STRING | remove*images.jpg | Use wildcards (*) to match filenames or paths |
| replace_text | STRING | /newpath/ | Text to replace matched text with when using 'replace' method |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMG_DB | LoadDB | — |