图像反推 (SillyDream)
Reverse any image back into a prompt, via your own OpenAI-compatible gateway
- image
- prompt
You've got a reference image you love and no idea what prompted it - or you want to re-prompt an image for img2img or image-to-video. SillyDreamImagePromptReverse (图像反推, literally "image reverse") is the half of the qianchi7/ComfyUI-SillyDream-PromptReverse pack that does that job: it sends your image to an OpenAI-compatible chat API and hands back a ready-to-use prompt string.
The name is a small lie, and that's the good news. "SillyDream" isn't a model - there's no checkpoint to download, nothing runs locally, no API key you must buy from the author. The node is a messenger. It takes your image, base64-encodes it, and posts it to whatever vision-capable model your gateway exposes, gpt-4o-mini by default. You own the endpoint, the model, and the key.
Why reach for it? The blank-page problem. Instead of staring at an empty prompt box, drop in a reference and get a structured starting prompt covering subject, appearance, action, clothing, scene, lighting, lens and style. That's the VLM-captioning role the KB's LLM-in-graph essay describes - caption an image to seed a generation or a video clip, or just to unblock yourself when you don't know what to write.
How it works
The mechanism is dead simple once you see it:
- Your
IMAGEtensor's first frame becomes a PIL image, encoded as JPEG at a descending quality ladder (92 → 55) with downscaling, kept under a 10 MB base64 ceiling. A huge 4K render won't blow past your gateway's body limit. - You only type
http://IP:3000intoapi_url- the node auto-appends/v1/chat/completions. It also handles an already-full URL, so both work. - It POSTs your
system_promptanduser_promptalongside the image as a data URL, withtemperature,top_p,seedandmax_tokens. - Retries on 429 and 5xx (three attempts with backoff), and the reply parser even falls back to
reasoning_contentfor reasoning-style models that think out loud before answering.
The output is a single prompt STRING - this node is not an output node, so wire it into a text encoder or a string node and keep building.
The inputs that matter
- image - any IMAGE socket; typically a
LoadImageoutput. - api_url - defaults to
http://127.0.0.1:3000, which is the author's demo gateway. Replace it with yours before you rely on it. - model_name - must match exactly what your gateway has configured. And it must be a vision-capable model, or the call errors.
- api_key - leave blank if your gateway needs no auth; otherwise it's sent as a Bearer token.
- language -
zhoren; it appends a "answer in Chinese/English" clause to your system prompt, so output follows your choice. - system_prompt / user_prompt - the Chinese defaults are genuinely decent for a t2i prompt; edit them if you want English defaults or a different output shape.
Installing it
Both nodes in this pack install together. ComfyUI Manager → Install via Git URL, paste https://github.com/qianchi7/ComfyUI-SillyDream-PromptReverse.git, then Restart (not just Reload - custom nodes only scan at startup). Manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/qianchi7/ComfyUI-SillyDream-PromptReverse.git
pip install requests Pillow numpy
That's the whole dependency list - requests, Pillow, numpy. No models, no heavy wheels. Search 图像反推 or SillyDream to find it (category Image/Prompt). The pack even ships prompt_playground.html, a standalone browser tool that does the same reverse-without-a-gateway dance if you want to test before wiring it in.
Troubleshooting
The failure modes are all gateway-shaped, and the README maps them cleanly:
- 404 -
model_namedoesn't match the gateway's configured name. The most common miss. - 401/403 - key wrong, or the key lacks access to that model.
- 429 - rate limited; the node retries, then gives up.
- "response isn't valid JSON" - your
api_urlpoints at a web page instead of the API. The error prints the full request URL so you can curl it and check. - Can't find the node after install - you didn't restart ComfyUI.
One honest warning, because this is an API-wrapper node: your key and your image leave the machine by design, and that's exactly the category that shipped malware once (the LLMVISION incident). The code here is small, open, MIT, and does nothing surprising - but point it at a gateway you control, use your own key, and don't park on the author's demo endpoint for real work.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| api_url | STRING | http://127.0.0.1:3000 | — |
| model_name | STRING | gpt-4o-mini | — |
| api_key | STRING | — | |
| language | COMBO | zh | 2 options: zh, en |
| system_prompt | STRING | 你是一位资深的图像分析师。观察用户给出的图片,写出一段可以直接用于文生图模型的提示词:覆盖主体、外观细节、动作与姿态、服装、场景与环境、光线、色调、镜头与构图、整体画面风格。只输出提示词正文,不要解释,不要加标题、编号或 Markdown 标记。 | — |
| user_prompt | STRING | 请反推这张图片的提示词。 | — |
| top_p | FLOAT | 0.900–1 | — |
| temperature | FLOAT | 0.700–2 | — |
| seed | INT | 00–4294967295 | — |
| max_tokens | INT | 20480–32768 | — |
| timeout | INT | 1205–1800 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| prompt | STRING | — |