LayerUtility: Florence2 Image2Prompt(Advance)
Florence2 Image2Prompt — turn Florence 2's many talents into one text output
- florence2_model
- image
- text
- preview_image
Florence 2 isn't just a captioner - it's a genuinely multi-task vision model, and this node exposes most of that surface through one task dropdown rather than needing eighteen separate nodes. The code here comes from yiwangsimple's florence_dw project, wrapped to plug into the pack's Florence2 model loader. Depending on which task you pick, this single node can caption an image at three levels of detail, generate PromptGen-style tags, run object detection, do dense region captioning, or handle a few other structured vision tasks - the eighteen task choices span all of it.
The task enum is the whole node, functionally: caption / detailed caption / more detailed caption give you three lengths of the same basic description (the default is more detailed caption), while description is a plainer variant. If you've loaded one of the PromptGen fine-tunes in the model loader, generate tags(PromptGen 1.5), mixed caption(PromptGen 1.5), mixed caption plus(PromptGen 2.0), and analyze(PromptGen 2.0) become useful - these are shaped specifically toward Stable-Diffusion-style prompt output rather than a plain description. Then there's a cluster of detection/localization tasks - object detection, dense region caption, region proposal, region proposal (mask), and more beyond what's listed - which shift the node from "describe this image" into "find and label regions in this image." text_input is only relevant for tasks that need a text query (like grounding a specific phrase); leave it blank for the pure captioning tasks. max_new_tokens and num_beams are the usual generation controls - more beams costs more compute for marginally better output. do_sample toggles sampling versus greedy decoding, and fill_mask is specific to Florence2's mask-filling capability, off by default. Outputs are text (the actual result, varies in format depending on task) and preview_image, which visualizes detection/region tasks so you can sanity-check what got picked out before it feeds downstream.
Install the pack via ComfyUI Manager (search "ComfyUI Layer Style Advance") or git clone https://github.com/chflame163/ComfyUI_LayerStyle_Advance into custom_nodes/, restart, run the requirements installer. You need the LayerMask: Load Florence2 Model node upstream to feed florence2_model in - this node has no model of its own. The model files download automatically on first use if you haven't grabbed them already, into ComfyUI/models/florence2.
If you switch task and get garbage or an outright error, the first thing to check is whether the task actually matches the loaded model version - the detection/region tasks and the PromptGen-specific tasks assume a compatible Florence2 checkpoint, and picking a PromptGen task against the plain base model (or vice versa) is a mismatch rather than a bug. Beyond that, this node inherits the pack's known Florence2 compatibility issue on newer transformers versions, fixed by copying modeling_florence2.py and configuration_florence2.py from the plugin's florence2_models folder over the files already sitting in ComfyUI/models/florence2 - a two-file overwrite rather than a full reinstall.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| florence2_model | FLORENCE2 | — | |
| image | IMAGE | — | |
| task | COMBO | more detailed caption | 18 options: caption, detailed caption, more detailed caption, description, generate tags(PromptGen 1.5), mixed caption(PromptGen 1.5), +12 |
| text_input | STRING | — | |
| max_new_tokens | INT | 1024 | — |
| num_beams | INT | 3 | — |
| do_sample | BOOLEAN | false | — |
| fill_mask | BOOLEAN | false | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| preview_image | IMAGE | — |