Plan Before Rendering Complex Images

    Complex image generation fails when prompts mix spatial relations, attributes, negation, counts, and readable text into a single denoising pass. This article explains a plan-then-render pipeline: turn the instruction into a checkable scene spec, render from that spec, and verify the result with detection, OCR, limited retries, and human review.

    Complex image generation is often treated as one sample: natural language goes straight into a diffusion process, and pixels gradually take shape in noise. For landscapes, materials, and lighting, that is often enough. Once the instruction includes left and right, containment, negation, counts, and readable text, failures cluster. The model can recognize visual concepts such as “girl,” “raincoat,” and “dog,” but it may not treat “on the left,” “not eating,” and “blue bench” as constraints that must all hold at once. The result is swapped attributes, ignored negation, and text that becomes texture. For developers, this is not an aesthetic issue. It is a problem of controllability and acceptance.

    1. Where the failures come from

    Diffusion models are good at producing locally plausible pixels. Composition, attributes, and text are global constraints. Common failures fall into four groups.

    1. Spatial relations are unstable. Even if the prompt says left and right, sampling may still swap the subjects, because position words constrain the loss more weakly than subject appearance.
    2. Attribute binding is wrong. Color, clothing, and objects are easy to mix up, especially when several entities share the same visual vocabulary.
    3. Negation barely works. “Not eating an apple” can still produce an apple, because “dog” and “apple” co-occur in the training distribution more strongly than the negation does.
    4. Text is treated as pattern. If letters and characters are learned only as texture, strokes break, mirror, or turn into unreadable symbols.

    A longer prompt should not be expected to repair structural errors by itself. “Deciding what the picture is” and “drawing the pixels” need to be separated.

    2. Plan first, then render

    A more reliable path mixes two capabilities instead of putting the entire burden on one denoising run.

    The planning stage uses an autoregressive sequence model to handle the instruction. It does not produce final lighting. It rewrites the sentence into a scene specification: which entities exist, their attributes, relative positions, counts, objects that are allowed or forbidden, and text content with an approximate region. Think of it as a shot list before drawing, not as pixels.

    The rendering stage then uses a diffusion model, or a similar generator, to fill in texture, lighting, and style from that specification. The renderer is responsible for whether the output looks like an image. The planner is responsible for whether it is the intended image.

    The value of this split is that the intermediate result can be checked. The plan can be read by rules or by another validation model. The rendered image can then be compared with the specification using detection, OCR, and sampled human review. A failure can be traced to a bad plan or a render that drifted, rather than ending as only a useless image.

    The flow below is pseudocode for engineering orchestration, not a vendor API:

    1. spec = planner.parse(user_instruction)
    2. spec = validator.check(spec) # entities, positions, negation, text
    3. if spec.invalid:
    4. return clarify_or_retry(spec.errors)
    5. image = renderer.sample(spec, seed, style)
    6. report = judge(image, spec) # boxes, OCR, attribute checks
    7. if report.failed and retries < limit:
    8. return renderer.sample(spec.tighten(report), new_seed)
    9. store(image, spec, report)

    The plan should stay structured so it does not collapse back into vague prose. For example:

    1. entities:
    2. - id: girl
    3. attrs: [red_raincoat]
    4. region: left
    5. - id: dog
    6. attrs: []
    7. region: right
    8. forbid: [holding_apple, eating_apple]
    9. - id: bench
    10. attrs: [blue]
    11. relation: behind_or_under(girl, dog)
    12. text: []

    Regions do not need exact pixel coordinates at the start. Begin with discrete relations such as left, right, above, below, in front, and behind, then refine to canvas ratios if needed. Locking coordinates too early removes compositional freedom. Locking nothing returns you to random sampling.

    3. What the planner should output

    A useful blueprint usually has six parts. Missing one makes it easy for the renderer to fill the gap on its own.

    • Entity list: number each object separately so that “red” does not modify several targets at once.
    • Attribute binding: attach color, clothing, and material only to the matching ID.
    • Spatial relations: left/right, above/below, front/back, containment, and adjacency, written as predicates that can be checked.
    • Count and state: one, two, sitting, empty-handed.
    • Negation list: objects or actions that are explicitly forbidden, treated as first-class constraints during validation rather than as an adverb in the prompt.
    • Text layer: the string to appear, its language, an approximate position, and whether decorative distortion is allowed.

    Negation needs separate handling. A generator’s default behavior is to draw the nouns in the prompt. In engineering terms, “no apple” should become a detection target: if the apple detection score in the finished image is above a threshold, mark the result as failed and resample or tighten the prompt. Do not assume the model “understood not.” Likewise, “left” should become a check of whether the subject box center falls in the left half of the canvas, not three more repetitions of the word “left.”

    4. On-image text is symbols, not texture

    Posters, covers, and infographics require readable text. If text is only image texture, the model imitates a stroke distribution that looks like writing without guaranteeing the correct character sequence. A sounder approach treats text as a symbol sequence: fix the string first, then decide the glyph and position of each character, and finally composite it with the background.

    In practice, choose among three tiers by reliability, from highest to lowest, instead of defaulting to the generator “writing” everything.

    1. Generate a text-free background, then overlay type with a layout engine. Brand names, prices, dates, and legal copy should follow this path, because font, line breaks, and compliance can be audited.
    2. Let the generator handle only short words or decorative titles, then read them back with OCR. If they do not match, redraw or switch to overlay.
    3. Do not give long sentences, multiple languages, or small type to the generator. The cost of failure is higher than setting the type yourself.

    The intuition behind character-level constraints is that the model must know which strokes form a glyph and that those glyphs must appear in a given order. Even then, complex characters, very small sizes, and strong artistic distortion still drop glyphs. The acceptance criterion should be “OCR matches the target string exactly,” not “it looks like there is text.”

    5. How to judge “more usable than the last version”

    When discussing a model update, avoid vague claims such as “smarter” or unproven percentages. A comparison that matters for a product should freeze the task set and look at four metrics separately.

    • Relation compliance: whether left/right, count, and containment match the specification.
    • Negation compliance: whether forbidden objects are absent.
    • Text accuracy: the exact-match rate of the target string, not a subjective “roughly similar.”
    • Visual quality: sharpness, anatomy, lighting, and style consistency. Blind human review is fine, but keep it separate from the first three.

    Compare under the same random seed, the same resolution, and the same retry budget. Only then can you tell whether the gain came from the model or from trying more times. If a new version is better only at lighting and still fails negation, the production path should keep detection and retries. A version bump is not a reason to remove the guardrails.

    6. Putting it on a production path

    A working image service is usually not a single synchronous call. Orchestrate it from general capabilities rather than binding it to a specific product model.

    After the user instruction enters the application layer, plan and validate first, then submit an asynchronous generation job. Store the original image, thumbnail, and specification JSON in object storage. Put job state on a queue. Log the prompt, specification, seed, and failure reason. Alert on timeout rate, retry rate, and OCR failure rate. When exporting a slide deck or an image package, export “background plus text boxes” instead of baking every word into pixels, so later copy changes do not require another sample.

    Retries need a cap. Each retry should change the seed or tighten the failed item, rather than sampling the same error distribution again. For marketing material, human review remains the last gate. A generator can lower the cost of a first draft. It cannot replace responsibility for brand, copyright, and factual text.

    7. What this still cannot do

    Planning plus rendering raises the rate at which constraints are hit. It does not guarantee a hit on the first try. Small objects, occlusion, rare combinations, and long text still fail. Detectors themselves produce false positives, so negation checks cannot rely on a single threshold. Also, do not treat a fluent explanation from the intermediate planner as proof that the picture is correct. The explanation is a hypothesis. The finished image is the evidence.

    For a development team, the practical goal is to turn uncontrolled sampling into a loop of specification, generation, detection, limited retry, and human fallback, and to pull text out of texture. Quality gains from later model versions can then be used reliably on posters, infographics, and presentation material, instead of remaining occasional striking samples.