The previous lesson made our first image. This one tunes the size and the step count.
diffusion() takes a handful of options besides prompt. The three you'll reach for first are width, height, and steps. Width and height control the output resolution in pixels. steps controls how many denoising iterations the model runs. More steps means more refine work, and eventually the image stops changing much.
A 512×512 image at 20 steps runs in a few seconds on a GPU. Doubling resolution roughly quadruples the work. The seed option lets us pin the random noise, so we can pass any integer and get the same image twice.
Four knobs on the same diffusion() call: width / height (multiples of 16) set resolution, steps is denoising iterations, seed pins the noise. The four-knob call would look like:
const result = diffusion({
modelId,
prompt: "a watercolor cat on a sunny windowsill",
width: 512,
height: 512,
steps: 20,
seed: 42,
});Same seed and same prompt, two calls produce byte-identical output like so:
const outputs = await result.outputs;
const first = outputs[0];
if (first) fs.writeFileSync("../../apps/desktop/output/image-gen/cat-watercolor.png", first);
console.log(`Generated ${outputs.length} image`);Run it twice with the same seed and we get byte-identical output. Change the prompt and we get a different image from the same starting noise.
Note: the seed is per-call, not per-model. Two
diffusion()calls with the sameseedand the samepromptproduce identical output; changing either breaks the reproducibility.
diffusion({ modelId, prompt, width: 512, height: 512, steps: 20, seed: 42 }).await result.outputs and write outputs[0] to disk.$ Run your code to see results
$