Automation turns a repetitive image-generation chore into a small program that runs it for you. Instead of clicking through prompt after prompt, define the work once, then let Python generate, organize, and save the results. A notebook acts like an ad hoc interface: less button-mashing, more repeatable output. section 3.0 section 3.4.5
For Stable Diffusion work, automation is most useful when one prompt is not enough. Code can generate many copies of several prompts with changing settings, while direct model access also makes newer models and deeper control available beyond a graphical UI. section 3.1 section 3.6
A practical automation workflow is:
- Create one reusable image-generation pipeline rather than rebuilding it for every image. section 3.5
- Store each job's prompt, height, and width in a dictionary keyed by panel or task name. section 3.5
- Set a single count for how many candidate images each job should produce. section 3.5
- Loop through the configurations, create an output folder, generate images with a seed, and save each file. section 3.5
- Review the generated collection and choose the result that fits each final panel. section 3.5
Generate a graphic-novel page without five rounds of manual clicking
Break a quote into five illustrated ideas, label them A–E, and give every panel its own prompt and dimensions. Set IMAGES_TO_GENERATE to 10. A nested loop visits each panel, makes its folder, generates ten candidates, and saves them for later selection. The important trick is not heroic code; it is putting the changeable details in configuration and leaving the repetitive work to the loop. section 3.5 section 3.6
Listing 3.3 Configuration for each of the images we want to generate
IMAGES_TO_GENERATE = 10
configs = {}
configs['A'] = {
'prompt' : "an illustration of a sky filled with black stars",
'height' : 800,
'width' : 1024,
}
configs['B'] = {
'prompt' : "an illustration, crazed men with a shadows coming out of their heads",
'height' : 800,
'width' : 600,
}
configs['C'] = {
'prompt' : "an illustration of twin suns setting over a alien looking lake",
'height' : 320,
'width' : 1800,
}
configs['D'] = {
'prompt' : "an illustration from a graphic novel, a pallid mask, frightening",
'height' : 800,
'width' : 800,
}
configs['E'] = {
'prompt' : "an illustration from a graphic novel, the king in yellow",
'height' : 800,
'width' : 400,
}This configuration listing shows the control panel for an automated run: one image count plus prompt and dimension settings for each panel. section 3.5
Listing 3.4 The loop for generating our panel images
import pathlib
for panel in configs:
pathlib.Path(f"./{panel}").mkdir(exist_ok=True) # Create the folder
generator = torch.Generator("cuda").manual_seed(1337) # Create the generator
for i in range(IMAGES_TO_GENERATE): # Iterate for the number of images we wish to create
image = pipe(guidance_scale=7.5,
generator=generator,
num_images_per_prompt=1,
**configs[panel] # applies our configuration as arguments
).images[0]
image.save(f"./{group}/{i}.png") # save the generated imageThis loop is the engine room: it creates panel folders, applies each configuration, generates repeated images, and saves the files. section 3.5






















