Nodes/ComfyUI_Fill-Nodes/FL KSampler SEG Captioner
ComfyUI Node

FL KSampler SEG Captioner

Auto-caption each region before you encode it

By filliptm·Created 3 years ago·Updated a day ago· 630
FL KSampler SEG Captioner
  • regions
  • source_image
  • regions
  • preview_image
api_key
modelopenai/gpt-4o-mini
prompt_templateDescribe the contents of this image region in 10-15 words. Focus on what's visible. Output only the description, nothing else.
prefix
suffix
max_tokens60
parallel_requests4
default_negative_promptblurry, low quality, artifacts
caption_first_frame_onlytrue
show_previewtrue

Second link in the Fill-Nodes SEG chain (Regions → Captioner → Encoder → FL_KsamplerSEG). Once FL_KsamplerSEG_Regions has carved your image into overlapping Voronoi cells, this node looks at what's actually in each cell and writes a short caption for it - automatically, via a vision-capable LLM. The point is to stop hand-writing per-region prompts: instead of you deciding "this corner is background sky, that corner is a face," the model tells you, and that caption flows straight into FL_KsamplerSEG_Encoder to become per-region conditioning.

How it works

For every region in the SEG_REGIONS bundle, the node crops the padded area out of source_image, base64-encodes it, and sends it to a vision model through OpenRouter - the model picker gives you GPT-4o-mini, Gemini Flash 1.5, or Claude Haiku 4.5, all fast, cheap vision models rather than frontier ones (sensible, since you're getting a one-sentence description, not a deep analysis). Requests fan out with bounded concurrency (parallel_requests) so you're not hammering the API sequentially region by region, and thumbnails + captions stream back live to an on-node widget as they land, so you can watch it work instead of staring at a spinner. caption_first_frame_only matters if your regions came from a video latent - set it and you only pay for one caption per region instead of one per frame.

The inputs and outputs that matter

  • api_key - you need your own OpenRouter key here. There's no bundled free tier; this is a pass-through to a real, billed API.
  • prompt_template - the instruction sent alongside each crop, defaulting to a terse "describe in 10-15 words" ask. Rewrite it if you want a different style of caption (more painterly, more literal, whatever your encoder step expects).
  • prefix / suffix - text glued onto every caption before it's used, useful for pinning a style tag across all regions without having to repeat it per-caption.
  • default_negative_prompt - not sent to the vision model; it rides along on the region data as the fallback negative for any region that doesn't get a usable caption.
  • Outputs: regions (the same SEG_REGIONS bundle, now carrying captions) feeds FL_KsamplerSEG_Encoder. preview_image is the composited thumbnail+caption grid so you can sanity-check what the model actually saw before you commit to a full sample.

How to install it

Via ComfyUI Manager: search "ComfyUI_Fill-Nodes" and install, or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/filliptm/ComfyUI_Fill-Nodes

then restart. This node specifically needs one more thing the base install won't hand you: an OpenRouter API key, which you get from openrouter.ai and paste into the api_key field (or wire it in from elsewhere - don't hardcode it into a workflow you share). filliptm's pack is a large, general-purpose collection - image FX, PDF tools, GPT/Gemini/Fal wrappers, this KSampler family - from one active solo author, so most of it needs nothing beyond ComfyUI itself; the API-integration nodes like this one are the exception.

Common issues & troubleshooting

Nothing happens / silent failures. No api_key means no captions - check that field first, and remember OpenRouter keys are billed per-request even for the cheap models this node defaults to.

Captions come back generic or wrong. Small, fast vision models like GPT-4o-mini and Gemini Flash 1.5 are good at "what's broadly in this crop" and weak at fine detail, especially on tiny or heavily-overlapping region crops. If a region is mostly texture or empty space, expect a vague caption - that's the model doing its honest best, not a bug.

It's slow on a big region count. parallel_requests caps concurrency for a reason - API rate limits - but if you cranked num_regions way up in the previous node, you're still making that many total calls. Budget for it, both in time and in API spend.

Regions with no caption still work. If a request fails or times out, that region just falls through to whatever default the next node (FL_KsamplerSEG_Encoder) applies - it doesn't break the chain, it just samples that region generically.

Category🏵️Fill Nodes/Ksamplers

Inputs (12)

NameTypeDefaultDescription
regionsSEG_REGIONS
source_imageIMAGE
api_keySTRING
modelCOMBOopenai/gpt-4o-mini3 options: openai/gpt-4o-mini, google/gemini-flash-1.5, anthropic/claude-haiku-4.5
prompt_templateSTRINGDescribe the contents of this image region in 10-15 words. Focus on what's visible. Output only the description, nothing else.
prefixSTRING
suffixSTRING
max_tokensINT6010–200
parallel_requestsINT41–10
default_negative_promptSTRINGblurry, low quality, artifacts
caption_first_frame_onlyBOOLEANtrue
show_previewBOOLEANtrue

Outputs (2)

NameTypeDescription
regionsSEG_REGIONS
preview_imageIMAGE