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:
| step | what it leaves behind | look at | order of |
|---|---|---|---|
| segment | the sub-parts, the silhouette and one mask per word | the three-column review image | 40 s plus 2 s per word |
| lineart | the lines on the source, one stroke each | the review image on top of the source | 35 s |
| complete | each group’s whole layer, and the account of what was invented | the completion review, and the restack | 6 min of model plus 10 s of merging |
| lines | each layer’s own lines, each stroke tagged with its layer and whether it was invented | one review image per layer, and the combined one | a dozen seconds per layer |
| draft | the draft’s plan, its strokes, and what Krita painted | the review images, per layer and per group | 1 min planning plus 1 min of Krita |
| paint | the painting plan, its strokes, each group’s mask, and what Krita painted | the same review images | 2-3 min planning plus 7 min of Krita |
| gauge | the criteria, and the matching-position crops | the table in the README | 15 s |
| trace | the plan, the strokes, and what Krita painted | the review images | 2 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”).