π° Florence2Run /v (from Kijai)
A vision-language model that reads your image, not just captions it
- image
- florence2_model
- image
- mask
- caption
- data
Florence2Run is the workhorse half of the Florence-2 pair that MaraScott vendored from Kijai's ComfyUI-Florence2. If you've ever wanted a single node that can caption an image, read the text in it, draw boxes around objects, or turn a region into a mask - without touching a ControlNet or a separate captioner - this is it. It's the node behind a lot of "auto-caption for training" and "describe what's in this image" workflows, and it beats the old CLIP-captioner days by a mile.
You feed it an image and a loaded Florence-2 model, pick a task, and it returns whatever that task produces: a caption string, a mask, an annotated image, or structured JSON.
How it works
Florence-2 is a Microsoft vision-language model - a sequence-to-sequence transformer that takes an image plus a task prompt and generates a text answer, which can then be converted back into images and masks. This node is Kijai's implementation, bundled in verbatim, so the mechanism is exactly what the ComfyUI-Florence2 pack does: the model's processor encodes your image, the model generates tokens (max_new_tokens, num_beams, do_sample, seed all behave like any HF generation settings), and the result is post-processed into the four outputs depending on the task.
It needs a Florence-2 model loaded first - either DownloadAndLoadFlorence2Model (also in this pack, under MaraScott/vendor) or the original from Kijai's own pack. The model itself is a FL2MODEL type, and it downloads from Hugging Face on first use into ComfyUI/models/LLM.
The inputs and outputs that matter
image- the image to analyze.florence2_model- the loaded model from the loader node.text_input- free text used by prompt-dependent tasks likedocvqaorreferring_expression_segmentation("the red car").task- the big dropdown, and the thing you'll actually change. 15 choices includingcaption,detailed_caption,more_detailed_caption,ocr,region_proposal,dense_region_caption,referring_expression_segmentation, and the PromptGen family.captionanddetailed_captionare where most people start.fill_mask- when on, regions from grounding-style tasks come back as a filledMASK.- Optional:
keep_model_loaded,max_new_tokens(default 1024),num_beams(3),do_sample(on),output_mask_select,seed.
Outputs: image (the annotated image with boxes/labels drawn), mask (segmentation mask when the task produces one), caption (the generated text), and data (JSON with the raw results - boxes, polygons, OCR text).
Installing it
Part of the MaraScott pack: ComfyUI Manager β search "MaraScott" β install β restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/MaraScott/ComfyUI_MaraScott_Nodes
Then restart ComfyUI. The model is the real install: pick microsoft/Florence-2-base (small) or -large (better, slower, fatter), and it downloads automatically. Give it a few GB of disk. The pack pins transformers==4.37.2 in its requirements - fine for Florence-2, but it can collide with other packs that need a newer transformers, so install this pack and any other LLM pack in the same session and be ready to reconcile versions.
Common issues
The model will unload between runs unless keep_model_loaded is on - leave it on if you're chaining several tasks or doing a big batch. flash_attention_2 requires extra deps and a compatible GPU; if the loader errors, switch attention to sdpa on the loader, which is the safe default anyway. And do_sample with a low seed makes captions a little nondeterministic - for stable outputs in a pipeline, turn sampling off or fix the seed.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | β | |
| florence2_model | FL2MODEL | β | |
| text_input | STRING | β | |
| task | COMBO | 15 options: region_caption, dense_region_caption, region_proposal, caption, detailed_caption, more_detailed_caption, +9 | |
| fill_mask | BOOLEAN | true | β |
| keep_model_loadedopt | BOOLEAN | false | β |
| max_new_tokensopt | INT | 10241β4096 | β |
| num_beamsopt | INT | 31β64 | β |
| do_sampleopt | BOOLEAN | true | β |
| output_mask_selectopt | STRING | β | |
| seedopt | INT | 11β18446744073709550000 | β |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | β |
| mask | MASK | β |
| caption | STRING | β |
| data | JSON | β |