Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The layered route

🧪 in progress (every completion and every per-layer lineart has to be reviewed) · segment -> lineart -> segment -> complete -> lines -> draft -> paint -> gauge, eight steps across three phases · a route is not code, it is the order the steps run in · one picture, one route, one subproject

in one line

Follow the artist’s stages. Lineart and parts come first, a person decides the layers by looking at them, diffusion completes each layer’s whole shape, each layer then gets its own lines, and a draft is laid out for a person to review; painting only starts once that passes. The layers are made for a person.

The chain

the layered route

  the picture ──► step01-segment    boundary barriers + the majority vote + growing from a
                     (ch. 1)          seed -> the subject cut into named sub-parts
        │
        ▼        step02-lineart     the lines on the source: two sources into one candidate
                     (ch. 2)          pool, scored against the source, trimmed, fitted
        │
        ▼        step03-segment     the kept lines become walls and the regions are cut
                     (ch. 1)          again; the table is inherited, not refilled
        │
   ═══ a person decides the layers: look at the region map and the lineart, then write the
       groups into the parts table ═══
        │
        ▼        step04-complete    the layering model gives each layer its whole shape; only
                     (ch. 3)          the hidden part is taken, the visible part is pinned to
        │                             the source, and stacking back is the acceptance test
        ▼        step05-lines       lineart extracted from each layer alone and arbitrated
                     (ch. 4)          against that layer's own image; lines that fall in the
        │                             invented area are accounted for as invented
        ▼        step06-draft       each layer's shape + its flat colour + its own lines ->
                     (ch. 5)          the layer tree -> Krita paints the draft
        │
   ═══ the gate: are the layers right - is each layer a whole object - are the lines right -
       does the invented part look right ═══
        │
        ▼        step07-paint       each group is painted by the method a person chose for it,
                     (ch. 6)          the lines take their weight from their own layer's image
        │
        ▼        step08-gauge       the criteria, a ruler per group, a ruler on each layer's
                     (ch. 7)          lines, and the comparison against the other route

On the numbering. The chain is numbered 01 to 08 with the lines-as-walls pass included. Skip that pass – it is optional – and every number after it drops by one; that shorter numbering is what the step templates assume in their defaults, so check the upstream constants at the top of each main.py rather than trusting the number in a heading.

The phases

phasestepsthe milestone
phase1-layers/segment · lineart · segment · complete · linesevery layer’s whole shape and its own lines
phase2-draft/draftthe draft, which is the gate
phase3-paint/paint · gaugethe finished painting and the criteria

A redone step stays in its own phase, and each phase’s README records that phase’s verdict.

Phase 1: the layers

step01-segment

The question it answers: which pixel belongs to which named part.

upstreamthe picture, and this picture’s parts table
producesthe subject cut into named sub-parts, one sub-pixel outline per sub-part, a numbered map of the raw regions, and one mask per word
a person doesfills the region numbers into the parts table; the first run stops after writing the region map and does not count as a step
look atthe three-column review image (the hand-written table, the majority vote, and what the vote changed)
the gateeach sub-part is the thing it is named after
if it failsfix the table’s regions, words or classes, and rerun the same step
costsneeds ComfyUI; well under a minute
the stage itselfch. 1 · the field names: appendix G

Unlike the one-shot route, this route uses the majority vote: the hand-written table is the prior, and the vote is what separates two things that share one region.

step02-lineart

The question it answers: where are the lines in this picture, and why is each one there.

upstreamthe segmentation
producesone stroke per kept line, each carrying which source proposed it, plus the review image that shows what was kept and what was dropped
a person doesoverrules individual lines when the arbitration got one wrong
look atthe review image on top of the source: blue for a kept AI line, brown for a kept contour, red dashes for dropped
the gatea line is there because the source has an edge there
if it failswrite the overruling into overrides.json and rerun this step
costsneeds ComfyUI, once per extractor; about half a minute
the stage itselfch. 2

These lines are not the finished lines. On this route the step has exactly two jobs: it supplies the walls for the next segmentation, and it is something to compare the per-layer lineart against. Every line that ends up in the painting is re-extracted later, per layer, by step05. That is why this step is rarely accepted on its own – it is accepted by what it enables.

step03-segment, with the lines as walls

The question it answers: does a real drawn edge fall inside one of my regions.

upstreamthe first segmentation, whose table it inherits; the lineart, whose kept lines become walls
producesthe same kinds of things as step01, from regions that the lines have cut apart
a person doesnothing new – the table is inherited, not refilled
look atthe same review image, plus close-ups wherever you expected the wall to change something
the gatethe wall moved what it should and left the rest alone
if it failsfix the lines upstream, not this step
coststhe same as step01
the stage itselfch. 1

This is not a redo, and it keeps its own number. step01 is not wrong; the second pass answers a question that could not be asked before the lines existed. Both steps stay in the chain and both stay numbered. From here on, “the segmentation” means this one.

Read the counts carefully. More hair pixels inside the neck close-up after the walls went in is not a regression – it is one real lock of hair finally being whole. Look at the close-up before you believe the count (ch. 17).

A person decides the layers

This is the first of the two human bars in the chain, and no amount of machinery replaces it. Look at the region map and at the lineart together, and write into the parts table which sub-parts make up each group – one group is one layer in the finished file, and the order they are written in is the occlusion order, which is the order they will stack in Krita. A layer that has to be split out of another one by an AI mask is declared here too.

Everything downstream is shaped by this decision: what gets completed, what gets its own lines, what gets painted by which method. Getting it wrong is cheap to fix now and expensive to fix after the draft.

step04-complete

The question it answers: what does the hidden part of each layer look like.

upstreamthe segmentation with the walls; the layering model’s output, which can be reused from an earlier run rather than regenerated
producesone whole layer per group, and an account of exactly which pixels were invented
a person doeschooses which of the model’s layers each group may draw its whole shape from
look atthe completion review image – per group: the occluded area, the completed shape, the layer alone, the outline – and the restack image: source, restacked, difference
the gatenothing shows through: there is no pixel that no group claims
if it failschange which of the model’s layers that group uses, and rerun this step
costsrunning the model fresh takes about six minutes and a dozen gigabytes of VRAM, so free the VRAM first by stopping ComfyUI
the stage itselfch. 3 · the field names: appendix G

Only the hidden part of the model’s answer is taken; everything visible is pinned to the source’s own pixels, because the model repaints what it can see and loses fingers, hair strands and lace when it does.

The gate used to be “the restack equals the source pixel for pixel”. It is not any more, and the reason matters: once each part’s method is allowed to redraw its own outline, the restack cannot equal the source. How far it differs is an account, not a gate. What is still absolute is that nothing shows through.

What is hidden is invented. The account of which pixels those are travels downstream with the layer, and everything built on top of them inherits the label.

step05-lines

The question it answers: what are this layer’s own lines, including the ones only it can see.

upstreamthe segmentation with the walls; the completed layers and their invented-pixel account; the lines on the source, for comparison only
producesone stroke per kept line, each tagged with the layer it belongs to and whether it was extracted from invented pixels
a person doesoverrules individual lines, the same way as in step02
look atone review image per layer, in the same three colours, plus the combined image where the kept lines are coloured by layer and the pale ones are the invented ones
the gatea line inside a layer is there because that layer’s own image has an edge there
if it failsoverrule it and rerun this step
costsone extraction per layer; one to two minutes
the stage itselfch. 4

Each layer is put alone on a flat ground and its lines are pulled from that picture, not from the source – which is the only way to get the lines that the layers above were covering up. A line extracted from pixels that were invented is invented too, and is marked as such; short invented lines with no support anywhere in the source are dropped by default.

The phase verdict

Phase 1 closes when the per-layer lines are through. Its README records, in order, what passed and what was moved aside – including the steps that were retired, because a retired step is part of how the surviving one got there.

Phase 2: the draft – the gate

step06-draft

The question it answers: are these layers something a person would accept.

upstreamthe segmentation with the walls; the completed layers; the per-layer lines
produceseach layer’s shape, a flat fill in its own local colour, its own lines, the layer tree, and the file Krita paints from it, with review images per layer and per group
a person doeslooks – this is the gate
look ateach layer on its own; each group on its own; the 1:1 close-ups; hide the upper layers to see the lines underneath
the gatesee below
if it failsback to whichever of the four upstream steps is actually at fault
costsone to two minutes, Krita included
the stage itselfch. 5

The gate

Four questions, and they are asked by looking, not by counting:

  1. Are the layers right? Is each group the thing a person would call by that name?
  2. Is each layer a whole object? Hide everything above it – is the kettle complete, or does it stop where something used to cover it?
  3. Are the lines right? Is each one there for a reason you can see in that layer’s own image?
  4. Does the invented part look right? It is invented; the question is whether it is plausible, not whether it is correct.

Where the answer is no, the fix is upstream – the groups, the completion’s choice of model layers, or an overruled line – and then the affected steps are rerun in order. Nothing goes on to painting until this passes. The verdict goes at the end of this step’s README.md under ## Verdict, which a rerun preserves, and into the gate record in the subproject’s README.

The images are to be looked at, not merely produced. Every time the baseline changes, go through the 1:1 close-ups of at least the face, the neck, a hand and a foot. Counting alone will lie to you (ch. 17).

Phase 3: the painting

step07-paint

The question it answers: what does this picture look like painted, part by part.

upstreamthe draft; the segmentation with the walls; the completed layers
produceseach group painted by the method a person chose for it, the lines given their weight from their own layer’s image, the background field, the layer tree, and what Krita paints from it
a person doeschooses each layer’s method in the parts table, before the step runs
look atthe same review images as the draft, plus the description count of the tree
the gateno pixel is written bare, and the tree stays within its node budget
if it failschange the method for the group that failed – not the ones that passed
costsabout ten minutes, seven of them Krita
the stage itselfch. 6, one page per body part · the field names: appendix G

There is no general way to paint. A person picks, for each layer, which method paints it; parts nobody has studied yet fall back to a baseline that copies the source’s light and shade. That baseline produces a picture, and it is not painting – it is kept as a ruler to beat, and a run that leans on it everywhere has been judged a failure before (ch. 19).

step08-gauge

The question it answers: how far is this from the source, and from the other route.

upstreamthe painting step, and the segmentation for the masks
producesthe criteria on the finished picture, a ruler per group, a ruler on each layer’s lines, and – when pointed at another subproject’s finished picture – matching-position comparisons
a person doesdecides what the numbers mean; the numbers do not decide
look atthe comparison crops, side by side at matching positions
the gatethe criteria of ch. 7, on a picture normalized to a fixed width and anchored to the source
if it failsthe fix is in the painting, not in the ruler
costsseconds
the stage itselfch. 7

This is also where the two routes finally meet: point this step at the other subproject’s finished picture and it produces the same crops from both, at the same coordinates. That comparison does not exist until both routes have been run on the same picture.

The phase verdict

A painting step that a person judges a failure is moved aside, and so is the gauge step that measured it – not because the rulers were wrong, but because their subject was. The readings are kept as the baseline a new method has to beat.

Redoing a step, and the second pass that is not a redo

A failed step is renamed with a legacy-wrong suffix and kept in its own phase; the rerun uses the same number. An experiment that was never part of the living chain gets legacy-experiment instead. Grep the subproject for the old name and fix the references; each downstream main.py names at the top which steps it reads.

Two things that catch people out:

  • A legacy directory can still be an upstream. The completion step’s expensive part is running the layering model; a retired experiment that already ran it is exactly where to read that output from, instead of spending six minutes and a dozen gigabytes of VRAM again. Retired does not mean dead.
  • A second pass is not always a redo. The second segmentation is not a rerun of the first – it answers a question the first could not – so both keep their numbers. Only a step that was wrong gives its number back.

When to take this route

Take it when the deliverable is a file an artist opens and edits: a layer per thing, each layer whole, each line accounted for, every shadow a layer that can be adjusted. It costs you a person’s attention at two bars – deciding the layers, and the draft – and it costs some likeness. Do not take it when all you want is a picture that resembles the source.

What it costs

The first run needs ComfyUI for the lineart and one mask per word; completion runs the layering model once (a few minutes, a dozen gigabytes of VRAM); per-layer lineart runs one extraction per layer; the finished painting has more than twice as many strokes as one-shot (the shapes are larger after completion), and the Krita half is on the order of ten minutes. Memory is not a problem: a dozen semantic layers, each layer’s strokes landing only inside its own area, a few gigabytes at most.

limitations

Its likeness is slightly below one-shot’s and its interiors are softer. One-shot piles dots onto the picture without regard to layers, so of course it resembles the source; this route paints each group on its own, and the boundaries between groups and the lineart are all repainted, so the difference is structural. Losing a vector shape per value band is what layering costs.

The way forward is a method of its own for each part (ch. 6), chosen by a person, not a return to the one-shot tree. What is hidden is invented (ch. 3), and a line extracted from invented pixels is invented too (ch. 4); both keep an account of exactly which pixels those are. A different picture means rewriting the parts table: the words, the groups, the prompts, the methods and the close-up coordinates all depend on the picture. And the layers are decided by a person while the lineart is only a wall and a reference – making the lines take part in the layering mechanically has not been done yet, and the lines-as-walls pass is the first step towards it.

On origin

The numbers, the tree, the close-ups and the matching-position comparison against the other route: ch. 19.