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

Ten minutes: from one picture to a finished .kra

✅ verified · the times are the order of magnitude at 4x (4096 wide) on a 16-core machine with 46 GB of RAM and 16 GB of VRAM, and vary with the picture

Every step is a directory with one main.py in it, copied from that stage’s template in the library repo, with the two blocks of constants at the top edited (the upstream steps’ paths, and the knobs), and then run. There are no other commands.

A new picture

uv run python dtp/tools/comfy.py                        # segmentation needs SAM
mkdir -p work/pic/input && mv pic.png work/pic/input/origin.png
cp dtp/templates/project/parts.py dtp/templates/project/README.md work/pic/     # the parts table (from the template) and the project README
mkdir -p work/pic/phase1-layers/step01-segment
cp dtp/templates/segment/main.py work/pic/phase1-layers/step01-segment/
uv run python work/pic/phase1-layers/step01-segment/main.py       # the first run stops after writing regions.png, the map of region numbers

Read the region numbers off the map that run wrote and fill them into parts.py – which regions make up which sub-part, ordered bottom to top by occlusion – then change the words to ask for, the classes and the groups to what this picture actually has (ch. 1 for what they mean, appendix G for the field names), and run the same main.py again under the same number, since the first run does not count as a step:

uv run python work/pic/phase1-layers/step01-segment/main.py       # 40 seconds; look at review-parts.png

one-shot

mkdir -p work/pic/phase3-paint/step02-trace && cp dtp/templates/trace/main.py work/pic/phase3-paint/step02-trace/
uv run python work/pic/phase3-paint/step02-trace/main.py          # 2 minutes reading the picture plus 5 minutes of Krita painting; the output is krita/final.kra, and the criteria table goes into the README

Look at composite-1x.png and crop-*-1to1.png in phase3-paint/step02-trace/krita/review/. That is all.

layered

For each step: mkdir the next numbered directory, copy the template, point the # ---- upstream lines at the earlier steps’ directories, and run it.

# step02-lineart     half a minute; the lines on the source, seen in lines-review.png; to overrule, write overrides.json and run it again
# step03-segment     WALLS = step02, ASSIGN_FROM = step01: cut the regions again with the lines as walls (40 s); look at review-parts.png
# step04-complete    6 minutes of See-through (free the VRAM first with fuser -k 8188/tcp) plus 10 seconds of merging; look at review-amodal.png and review-restack.png
# step05-lines       1-2 minutes; each layer's own lines, seen in lines-<group>-review.png / review-lines.png
# step06-draft       1-2 minutes; the gate: krita/review/ per layer, per group and the 1:1 close-ups -- a person looks before going on   (phase2-draft/)
# step07-paint       10 minutes (7 of them Krita); the finished krita/final.kra          (phase3-paint/)
# step08-gauge       the criteria table, the ruler on the lines and the per-group rulers; REF_FINAL = another subproject's final.png, for matching-position comparisons
mkdir -p work/pic/phase1-layers/step02-lineart && cp dtp/templates/lineart/main.py work/pic/phase1-layers/step02-lineart/
uv run python work/pic/phase1-layers/step02-lineart/main.py

What each step gives you, and how long it takes:

stepwhat it leaves behindlook atorder of
segmentthe sub-parts, the silhouette and one mask per wordthe three-column review image40 s plus 2 s per word
lineartthe lines on the source, one stroke eachthe review image on top of the source35 s
completeeach group’s whole layer, and the account of what was inventedthe completion review, and the restack6 min of model plus 10 s of merging
lineseach layer’s own lines, each stroke tagged with its layer and whether it was inventedone review image per layer, and the combined onea dozen seconds per layer
draftthe draft’s plan, its strokes, and what Krita paintedthe review images, per layer and per group1 min planning plus 1 min of Krita
paintthe painting plan, its strokes, each group’s mask, and what Krita paintedthe same review images2-3 min planning plus 7 min of Krita
gaugethe criteria, and the matching-position cropsthe table in the README15 s
tracethe plan, the strokes, and what Krita paintedthe review images2 min reading the picture plus 5 min of Krita

The file names are fixed and are all in appendix F.

Each step’s README.md opens with the table of numbers main.py wrote and ends with ## Verdict, written by a person (pass or fail, and why; a rerun does not overwrite it). When a step is judged a failure: mv stepNN-<stage> stepNN-<stage>-legacy-wrong-1 to move it aside, and the rerun uses the same number – the living chain is always consecutively numbered.

Running a long job

In the background, with absolute paths, logging to disk:

(uv run python /abs/work/pic/phase3-paint/step07-paint/main.py > /abs/work/pic/phase3-paint/step07-paint/run.log 2>&1; echo "exit $?" >> /abs/work/pic/phase3-paint/step07-paint/run.log) &
grep -aE "\[paint\]|\[stage\]|JOB (OK|FAIL)|Traceback" /abs/work/pic/phase3-paint/step07-paint/run.log | tail

A working directory cd-ed into in one command carries over to later calls, so a background chain uses absolute paths throughout. Before starting one, pgrep -a -f main.py shows whether another is already running – a process left by a crashed session will write into the same directory as yours and queue work in ComfyUI at the same time (clear the queue with POST /queue {"clear": true} and /interrupt). Kill Krita with pkill -x krita and ComfyUI with fuser -k 8188/tcp, and never pkill -f (see “Installing and self-checking”).