Illustration → Live2D
Output: Layered PSD → Animatable Live2D model (.moc3 + idle/blink/nod/shake actions + physics + texture set + Cubism .cmo3/.can3 project).
Three-stage pipeline, heavy work all in the cloud:
Cloud GPU (~4 min/image) Local CPU (few minutes, zero GPU)
See-through layer separation ──23-layer PSD──▶ Missing pixel repair ──▶ PSD2Live auto-binding ──▶ Export moc3
1. Determine Composition (Crucial – Do Not Skip)
| Input | Facial Feature Layer Pixels | Conclusion |
|---|---|---|
| Full-body vertical 1280 | 8,619 | Face covers only 0.4% of canvas; facial feature layer is poor |
| Half-body close-up 1280 | 30,547 | ×3.5 |
| Half-body close-up 1536 | 94,382 | ×11 (face layer ×12.9) |
See-through's preprocessing is center_square_pad_resize: first pad the image to a square, then scale the longer side to resolution. Therefore:
- Vertical full-body images waste half the canvas (character scaled by long side, both sides empty); cropping away left/right whitespace yields no benefit;
- The correct approach is to crop to half-body (head + shoulders + upper torso), making it nearly square;
- Use 1536 for
resolution(model's hard limit), video memory is only 6.7 GB – do not skimp.
Crop position can be reverse-engineered from the previous round's results: the art.psd.json file contains xyxy (canvas coordinates) for each part; convert using original = canvas / scale - pad_offset to locate the head/hands on the original image.
2. Cloud Layer Decomposition (See-through)
cd /root/autodl-tmp/see-through
python inference/scripts/inference_psd_quantized.py \
--srcp /root/autodl-tmp/art_bust.png --save_dir /root/autodl-tmp/out \
--save_to_psd --tblr_split \
--quant_mode nf4 \
--repo_id_layerdiff /root/autodl-tmp/models/seethroughv0.0.2_layerdiff3d_nf4 \
--repo_id_depth /root/autodl-tmp/models/seethroughv0.0.1_marigold_nf4 \
--resolution 1536 --resolution_depth 768 --num_inference_steps 30 \
--no_group_offload --no_cpu_offload --seed 42
--repo_id_*can accept local directories – pre-download the models to run offline;- Use the official NF4 quantized versions (
..._layerdiff3d_nf4+..._marigold_nf4, total 5.31 GB; full precision is 12.51 GB); - The SAM model (
l2d_sam_iter2) is not required in the main pipeline – do not download; - Measured on 4080S: peak VRAM 6.7 GB, layerdiff 219 s + marigold 11 s + PSD assembly 3 s, total ~4 min per image;
group_offload/cpu_offloadare enabled by default (for low VRAM); for 24+ GB cards, add--no_group_offload --no_cpu_offloadfor speed.
Mandatory: multi-seed drawing. The community consensus that "facial features need to be drawn multiple times" is true. Run 4 seeds (change --seed, ~0.15 yuan each), then use pixel statistics to score and pick the best – do not rely on the naked eye: key metrics are face layer pixel count, and left/right eye white distribution balance (>4000 on one side and <900 on the other means a bad image – only one eye was generated).
Each seed must use a different input filename (art_s1.png, art_s13.png...), otherwise output directories will overwrite each other.
3. PSD Repair: Restoring Missing Pixels from Decomposition
See-through often completely fails to generate props (umbrella surfaces), sleeves, and some hair strands (one full-body image lost 37.7% of pixels). Fix:
- Compute the missing mask:
missing = original alpha > 16 AND (union of all layers' alpha) == 0; - Multi-source BFS to find the nearest layer for each missing pixel (implemented with numpy iterative dilation, 300 iterations sufficient);
- Cut independent repair layers by ownership, insert immediately after the corresponding layer:
| Nearest Layer to Missing Pixel | Insert After | Measured Amount |
|---|---|---|
| objects | After props layer (umbrella) | 172k px |
| handwear | Above arm layer (sleeves) | 53k px |
| back hair / front hair / topwear | After each respective layer | 204k px |
| Distant scattered (BFS >300 rounds) | Merge into props patch | 62k px |
Key property: The missing mask is defined as "pixels not covered by any generated layer," so the repair layer will not occlude any existing content regardless of its position (even if placed on top). This makes the repair safe.
Result: Missing 37.7% → 2.0%; umbrella area coverage 99.8%, sleeve area 93–97%.
Modify PSD using psd-tools, rebuilding from scratch (PSDImage.new + PixelLayer.frompil(im, psd, name, top, left)), note:
- The parameter name is
namenotlayer_name(if misspelled, all layers will silently be namedLayer, and PSD2Live cannot recognize semantic roles); - The order of
descendants()is bottom-to-top – simply replicate; - Patch layer names can be arbitrary (unknown names will be assigned to the
objectsrole by PSD2Live), but existing layer names must be preserved exactly.
4. Headless PSD2Live Driver (Local, No GUI Interaction)
The desktop app includes a Streamable HTTP MCP, default at http://127.0.0.1:23871/mcp. The token is stored in the registry as plain text at HKCU\Software\JavaSoft\Prefs\io\github\psd2live\agent under agent_mcp_bearer_token (Java Preferences escapes: /x equals uppercase X, // equals slash). Requests require headers: Authorization: Bearer <token> and Accept: application/json, text/event-stream.
Calling convention: Each tool's parameters are wrapped in a request object, e.g., {'request': {...}}. For workspace_apply_edits, edits is [{'operation': ..., 'request': {...}}]; the inner request must NOT contain request_id/state/project_id (will cause unknown field errors).
Full pipeline:
workspace_inspect {scope: project} Get state / project_id (must re-fetch after each edit)
project {op: import_psd} Import PSD (job_backed, use job{op:wait} to wait)
workspace_apply_edits [model_apply_preset] Physics preset: front_hair / back_hair / clothing
workspace_call {operation: layer_draw_order} Explicit draw order
project {op: export_model} Export entire model family
view {op: render_model} Render verification image
workspace_callcan invoke any operation not exposed as a tool (only 25 streamlined tools are published by default);- On import, PSD2Live automatically recognizes layer names in Chinese, English, Japanese, Korean and splits left/right (See-through's
eyewhite/irides/eyelash/eyebrowdirectly correspond, auto-generatingeyewhite-l/retc.); layer_draw_ordersets explicit override values for rendering (0..1000), not list positions – list order remains unchanged, but rendering order changes (verified with A/B in the same project); smaller values render further back;- Render results are returned as base64 image blocks (not file paths); decode and save yourself;
- The request for
view_render_modelmust includeviewport({mode: canvas_rect, left, top, width, height});view_render_layerhowever does not accept viewport.
5. Verification Discipline (Hard-Earned Lessons)
- Visual retelling will mistake left and right. I received oscillating answers to the same question, and after adjusting twice based on it, both were reversed. Always judge left/right using coordinates and pixel statistics (e.g., left eye white 1753 px vs. right eye white 3425 px – hard data), use visual models only to judge similarity or ghosting.
- Same-project A/B comparison: To verify if a change took effect, render one image before the change and one after within the same project – do not compare across different projects (I misjudged once because of this).
- Area coverage ratio is more reliable than "does it look correct":
coverage = (intersection of original alpha and composite alpha).sum() / original alpha.sum(). - When the visual model says "missing/blurry" first check the numbers: encountered a case where the visual model claimed the umbrella surface was lost, but actual coverage was 85.5% (equal to the original); the real problem was edge ghosting.
6. Resources and Pitfalls
- PSD2Live continuously importing multiple large PSDs will grow memory to 3.7 GB and freeze the GUI (the process actually has
Responding=True, just building meshes). Criterion: restart if memory exceeds 3 GB; - Projects must be saved as
.psd2live(zip format) viaproject{op:save_as}. The exported.psd2live.jsonis just metadata sidecar; reopening withproject_openwill reportzip END header not found; - Repair layers are static: props like umbrella surfaces work fine, but sleeve patches do not follow arm movement – large motions will misalign. The root fix requires merging patch pixels into dynamic layers (moving textures and meshes);
- Cloud network (tested on AutoDL): GitHub
git cloneis throttled to 12 KB/s, but codeload tarball is 3 MB/s; huggingface.co / xethub / GitHub release attachments are completely unreachable from the instance; large files always download with multiple connections (8 shards); Alibaba Cloud pip mirrors have broken PEP 658 metadata (causes uv to fail outright) – swap to Tencent or Tsinghua mirror; uv is two orders of magnitude faster than pip; - Long tasks use
nohup ... &to detach from SSH then poll logs;pkill -f patternwill match its own shell and commit suicide.
7. Scripts and Paths
Project directory: D:/dshproject/live2d-exp/
| Script | Purpose |
|---|---|
remote.py | SSH channel (run / sh / shbg detach / put / get / tail), key authentication |
sftp_tree.py | Parallel directory upload/download (put / get / run, -j concurrency) |
sync_tree.py | Size comparison + resumable transfer (only transfers the difference after interruption) |
p2l.py, p2l_build.py, build_parts2.py | PSD2Live driver: import → preset → layer order → export → render |
psd2live_mcp.py | Minimal MCP client (tools / call / ops) |
bfs_label.py + build_parts.py | Missing pixel relocation + per-part PSD reconstruction |
score_run.py, score_eyes.py | Seed scoring (layer coverage, facial feature pixels, left/right eye balance) |
verify_parts.py, region_stat.py | Composite vs original IoU and per-region coverage |
Outputs: p2l_parts/ (model family), out_seeds/art_s13* (each seed's PSD and layers), preview/ (comparison images).