diff --git a/README.md b/README.md index 576a56b..9f34a92 100644 --- a/README.md +++ b/README.md @@ -27,19 +27,8 @@ git clone https://github.com/RockyHong/ComfyUI-FilePathsFromFolder.git 3. Copy folder `ComfyUI-FilePathsFromFolder` into `ComfyUI/custom_nodes/` 4. Restart ComfyUI -## Choose how you want to iterate - -- **Option A — External loop (index-based): get a file path list + pick one path per iteration** ([jump](#option-a-external-loop)) - - Use `LoadFilePathsFromFolder` → `GetPathByIndex` (UI: `Load File Paths From Folder` → `Get File Path By Index`) - - Best when you already have a loop/for/while node from another pack, and you just need a clean “files-by-extension” input. - -- **Option B — This repo’s loop node: run downstream nodes once per file (list batching)** ([jump](#option-b-internal-loop)) - - Use `FilePathsForLoop` → your processing nodes → (optional) `FilePathsEnsureExecution` → `FilePathsLoopClose` - - UI: `File Paths For Loop Start` → your processing nodes → (optional) `File Paths Loop Ensure Execution` → `File Paths Loop End` - - Best when you want a simple, no-extra-deps “loop”: ComfyUI runs downstream nodes once per file via list batching. - -## Option A — External loop (index-based) +## Integrate with external for/loop nodes (index-based) Use this when you already have an external loop/for/while node pack and you want to drive it with “files in a folder” (by extension). @@ -60,7 +49,7 @@ Use this when you already have an external loop/for/while node pack and you want 6. Do your processing + save/export inside your external loop pack -## Option B — Internal loop (this repo’s loop node, list batching) +## Built-in simple for-loop node (list batching) Use this when you want the simplest setup: `FilePathsForLoop` returns lists, and ComfyUI runs downstream nodes **once per file** via list batching. (UI: `File Paths For Loop Start`) @@ -83,12 +72,13 @@ Use this when you want the simplest setup: `FilePathsForLoop` returns lists, and ### Memory note -`FilePathsForLoop` uses **ComfyUI list batching** (it sets `OUTPUT_IS_LIST`). This is not a “while/for loop” that runs one full item end-to-end. +`FilePathsForLoop` uses **ComfyUI list batching** (`OUTPUT_IS_LIST`): ComfyUI may run the workflow **one node at a time for all files**, rather than finishing file 0 completely before starting file 1. -- **What you may observe**: ComfyUI often runs **node-by-node for the batch**. So a route like `Load X From Path` → `Process` → `Save` can look like “all loads”, then “all processing”, then “all saves” (not Load→Process→Save per file). -- **Why memory can grow**: batching can keep more intermediate results “alive” until later nodes run; heavy nodes (models / large frames / big tensors) can push VRAM/RAM peak usage. -- **Practical tip**: if you notice memory climbing, add “Clean VRAM” / “Clean RAM” (or equivalent) at safe points after heavy steps. -- **If you need strict sequential iteration** (finish item 0 completely before item 1): use an external loop/for/while node pack and Option A. +- **What you’ll see**: it may run like **“load all → process all → save all”**, not “load → process → save” per file. +- **When this is good**: if you want to run many files with the **same model/settings**, batching can help keep the model “warm” and avoid offload/reload each file. +- **Why memory can climb**: more intermediate results may stay in RAM/VRAM until later nodes run. +- **Tip**: if memory keeps increasing, add a “Clean VRAM” / “Clean RAM” (or similar) node after heavy steps. +- **Need true one-file-at-a-time?** Use an external loop/for/while node pack that runs each file start→finish before moving on. ## License