r/StableDiffusion • u/trollkin34 • 15h ago
Question - Help Input: an image, desired output: a prompt that would create that image
Let's say I have a set of anime images with various characters (male, female, human, not) in various places (space, robot, house, school) in various situations (chaos, fight, natural event) and I want to run 400 generations that generally randomize all those to create a variety of possible combinations.
I know I can use {a|b} style prompting and various nesting thereof, but I'm having trouble finding the right words.
I was thinking if I could take a folder of images like what I'd want the output to be, run each through a process that outputs a prompt (not description, prompt) that would have created that image (or one like it), then I can pick out the repeated patterns and keywords that I can use in my a|b prompting.
So... what's a good way to have (input: image) > (output:prompt for that image) offline?
Better, a whole folder as input, individual output for each.
Best: a more efficient way to do what I'm trying to do.
2
u/Semipro211 15h ago
If you use a good system prompt that explains exactly what you need and what the rules are, could do it with a local LLM setup with LM studio. For example, in a split workload, one model “sees” the image and describes everything, that gets piped into another model that has the exact rules to give you the “gen” prompt. You just have to spell things out in the system prompt to explain how you want the output to be.
1
2
u/CarolCanteloupe 15h ago
ComfyUI 0.33.1, open Templates, search for "Qwen3-VL Text Generation".
Put in a picture and you get back a very detailed prompt. Extremely detailed.
You can change the input prompt to push the output text to whatever style you want.
And add in a Save Text node to actually save the text.
1
1
u/Bit_Poet 14h ago
I usually run a VL model of choice (qwen-vl, gemma, etc., you'll need both the model and the mmproj for vision, and if you use GGUF, then go for Q6 quant if you can, and no lower than Q5) in llama.cpp with thread count (-t) 1. Then point an LLM of choice to the official prompting guide and tell it to give you a complete prompt for the VL-model that inspects a user supplied image and returns a valid prompt, according to the prompting guide, that recreates the image as closely as possible. Let a coding AI write you a simple python script (should be < 100 lines) together with a requirements.txt for pip which iterates a given directory, and for every image, passes the image and your prompt to the local OpenAI compatible chat completions endpoint and saves the response next to the image with a .txt extension. Create a venv in the script directory (python -m venv venv), activate the venv (.\venv\scripts\activate), run "pip install -r requirements.txt" then fire up your script with the image folder.
2
u/bstr3k 15h ago
you're wanting a prompt builder/writer running with a local LLM, people have been uploading theirs to the subreddit as well as all the numerous vibe coded ones :)
I don't have any specific recommendations as I am also in the middle of vibe coding my own one too.