Inside ComfyUI: one picture in 12 seconds
The pictures are made by a program called ComfyUI running on my own computer. ComfyUI lets you build an image generator out of blocks connected by wires. My script builds the same little diagram every time and sends it to ComfyUI over a local connection. Here is what is in it.
1. Load the model
The model is Juggernaut XL, a Stable Diffusion XL model that is good at soft-lit, realistic animals.
2. Read the prompt
The prompt is the recipe from Part 2 plus a fixed style line that gives every picture the same look:
professional photograph, soft natural window light, shallow depth of field, warm gentle colors, creamy bokeh, sharp focus on the subject, high detail, heartwarming, adorable
So a finished prompt reads like "a baby fox, in a sunny kitchen window, wearing a tiny knitted hat, professional photograph, soft natural window light..." and so on.
3. Read the negative prompt
A negative prompt is a list of things to steer away from. Mine is:
text, watermark, signature, logo, lowres, blurry, deformed, disfigured, extra limbs, extra legs, extra ears, fused bodies, distorted face, cross-eyed, creepy, scary, uncanny, dark, gloomy, human, person, hands, cartoon, 3d render, oversaturated
Most of it is a list of the ways AI pictures go wrong: extra legs, fused bodies, strange faces. Some of it keeps the mood right: nothing creepy, dark or scary.
4. Make an empty canvas
ComfyUI starts with a blank "latent" image at the size for this picture. The gallery uses a few shapes so it has variety: a wide one at 1216 by 832, a tall one at 832 by 1216, a square at 1024 by 1024, and a tall phone-screen shape at 768 by 1344.
5. Sample
This step does the drawing. It starts from pure noise and removes the noise a little at a time, guided by the prompt. My settings:
- 28 steps of denoising.
- CFG 5.5. This is how strongly the model follows the prompt. Higher is more literal and often more harsh.
- The DPM++ 2M sampler with the Karras schedule. These are the method and the pacing of the noise removal.
- A random seed. The seed is the starting noise. It is why two pictures from the same words look different.
6. Decode and save
The result is turned back into pixels and saved as a PNG. The script also writes the small receipt file with the words, the seed, the size and the tags.
On my graphics card the whole thing takes about 12 to 18 seconds a picture, so a night's 30 pictures take well under ten minutes.
Other models for special batches
Some collections use a different model. FLUX.2 klein 4B makes a picture in only 4 steps, which is why I use it for curated sets like baby elephants with everyday jobs and the pastel spaceships. It can also follow a reference picture to keep a character looking the same from picture to picture.
Why it all runs at home
Everything happens on my own machine. No picture and no prompt is sent to a cloud service, and there is no per-picture bill. The cost is a graphics card, some electricity and my time.
Next: how the gallery keeps the clutter out.