The model draws. The code decides what ships.
A Python pipeline that produces print-ready coloring books, using deterministic code to enforce everything a generative model will not do reliably.

The call
Let the model draw, but never let it decide what ships.
Generative image tools are unreliable in specific, predictable ways: a character drifts between pages, line weight wanders, frames sit off-centre, resolution is not print-safe. The temptation is to fix that with better prompts. I did the opposite. I mapped exactly where the model fails and specified deterministic code to cover each gap, built with AI development tools: frame detection and redraw, 1-bit thresholding, composition measurement with automatic retry, cover lettering composed in code, and PDF assembly with the printer's gutter rules. The model produces. The code decides what is good enough to print.
The situation
AI image tools are good at making one nice picture. They are bad at making the same character forty times. Draw a shepherd boy on page one and by page twelve he has different hair, a different face and a different nose. For a coloring book, where a child follows one character through a story, that is not a cosmetic problem. It is the product failing.
The other half of the problem is print. A coloring page has to be pure black line on white at a printable resolution, inside a consistent frame, with no shape so small a crayon cannot fill it. None of that is something you can ask a model for and trust the answer.
What I built
A pipeline that splits the work between the model and the code, on purpose.
The consistency problem is solved with a two-step anchor. A colour cover is generated first and defines the character. From that cover, a black-line character sheet is generated. Then every interior page is generated against the character sheet rather than against loose text. The character has a reference to hold on to, so he stops drifting.
Everything the model does not do reliably is handled by deterministic code, which I specified and built with AI development tools: frame cropping and redraw, 1-bit thresholding, composition measurement with automatic retry when a page comes back wrong, cover lettering composed with PIL, and interior assembly with the printer's gutter requirements. The system also generates its own publishing guide.
What I would tell someone starting this
The instinct is to keep refining the prompt until the model behaves. That instinct is expensive and it does not converge. The faster path is to find the boundary, decide what the model is actually good at, and put ordinary code on everything on the other side of that line. In this project the model is a drawing tool. The pipeline is the product.
Where it stands
Five books have moved through the pipeline, one finished and published under a shared byline, the rest in production. The interior pages carry no text, so a new language is a new book at no extra generation cost. The one check still done by eye is minimum printed shape size, around seven millimetres, and closing that in code is the next piece of work.
Logbook
How it got here
Scroll to move through the steps. Where there is a before and after, drag the handle to compare.
The anchor
The cover defines the character.
A colour cover is generated first. From it, a black-line character sheet. Every interior page is drawn against that sheet, so the character stops drifting across forty pages.

01 / 07Step 1, the cover. Step 2, the character sheet drawn from it.




