Nodes/Eric/Add Folder to Index
ComfyUI Node

Add Folder to Index

The one-time grind that makes search instant forever

By EricRollei·Created 7 months ago·Updated 7 months ago· 2
Add Folder to Index
  • index
  • model
  • index
  • status
folder_path
recursivetrue
batch_size16
thumbnail_size768
include_videostrue
include_documentstrue

This is the node that does the actual work of the whole pack. Add Folder to Index walks a folder, runs every image (and optionally video and PDF page) through your embedding model, and files the resulting vectors plus thumbnails into an index. It's the one-time grind that makes searching instant later - which is why you should expect this node to be slow the first time and completely fine afterward.

The mechanism is unglamorous but worth knowing. The node collects supported files from the folder - images (jpg, png, webp, tiff, heic, RAW via rawpy, etc.), videos (mp4, mkv, mov...) by sampling frames, and PDF pages rendered at 150 DPI - encodes them in batches through your EMBEDDING_MODEL, and appends the vectors to the index's FAISS file while recording paths and thumbnails in its SQLite database. It shows a ComfyUI progress bar and checkpoints its saves as it goes, so a crash mid-index doesn't lose everything. Duplicate and already-indexed files get skipped; failures are counted in the status string rather than killing the run.

The inputs that matter

  • folder_path - absolute path to the directory. That's the whole job; the rest are tuning knobs.
  • batch_size (default 16) - images per encoding batch. Higher = faster but fatter VRAM. On 12GB cards, drop to 4–8; the README suggests 4 for 12GB, 8 for 24GB.
  • recursive (default true) - include subfolders. Turn off if you're indexing a shallow, tightly-curated folder.
  • thumbnail_size (default 768) - the stored thumbnail's max dimension. Bigger thumbnails cost disk and make the reranker slower, not the search itself.
  • include_videos / include_documents (both default true) - flip these off if you only care about stills; video indexing especially is a big chunk of the time.

Outputs

It returns the same SEMANTIC_INDEX (so you can chain more folders into it) plus a status STRING with the counts - e.g. Added: 12847, Skipped: 12, Failed: 0, Videos: 3, PDFs: 2 (40 pages). Wire the status into a Show Text node if you want to see it.

Install

Same pack install as everywhere else: ComfyUI Manager (search "Semantic-Search") or git clone https://github.com/EricRollei/Semantic-Search into custom_nodes, then pip install faiss-cpu "qwen-vl-utils>=0.0.8" transformers accelerate pillow. Two optional extras matter specifically for this node: opencv-python-headless if you want video indexing to work, and pymupdf for PDF support - both are listed in the pack's extras, not the core requirements.txt, so they won't be installed by default.

Where people get burned

  • "Error: Folder not found" - path typo, or you pointed it at a file. Also note it wants a filesystem path; it can't index ComfyUI's own output folder by name.
  • Dimension mismatch - your model and index disagree on embedding_dim. Create the index to match the model.
  • Painfully slow indexing - the README flags PyTorch 2.9.x's 3D-convolution regression; upgrading to 2.10+ can be a multi-factor speedup. Lower max_resolution on the model or batch_size if it's a VRAM problem instead.
  • Videos silently skipped - no opencv-python-headless, no video indexing. Check the status string's counts to see what actually got in.

Expect the first folder to take a while. That's the tax; the payoff is every search after it is effectively free.

CategoryEric/SemanticSearch

Inputs (8)

NameTypeDefaultDescription
indexSEMANTIC_INDEX
modelEMBEDDING_MODEL
folder_pathSTRING
recursiveoptBOOLEANtrue
batch_sizeoptINT161–64
thumbnail_sizeoptINT768256–1024
include_videosoptBOOLEANtrueAlso index video files (mp4, mkv, avi, etc.)
include_documentsoptBOOLEANtrueAlso index PDF documents (each page indexed separately)

Outputs (2)

NameTypeDescription
indexSEMANTIC_INDEX
statusSTRING