zi2zi
Operate zi2zi legacy Chinese/Japanese/Korean font style transfer workflows: paired glyph data preparation, TensorFlow 1.x training, inference, interpolation, and generator export.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- zi2zi
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Operate zi2zi legacy Chinese/Japanese/Korean font style transfer workflows: paired glyph data preparation, TensorFlow 1.x training, inference, interpolation, and generator export.
- disable-model-invocation
- true
02 资源文件 6
- 参考文档references/compatibility.md3.4 KB
- 参考文档references/repo-provenance.md2.3 KB
- 参考文档references/repo-routing-metadata.json315 B
- 参考文档references/troubleshooting.md3.1 KB
- 参考文档references/workflow-overview.md3.4 KB
- 脚本scripts/zi2zi_smoke_plan.py2.9 KB
03 SKILL.md 正文
zi2zi
Use this repo skill when a task is about zi2zi, the legacy TensorFlow 1.x conditional GAN for Chinese, Japanese, Korean, or other font style transfer. The skill is a router plus compact operating context; read the linked sub-skills for concrete commands, data formats, validation checks, and troubleshooting.
Use this skill when
- The user wants to create zi2zi training data from source/target fonts.
- The user has glyph pair JPGs and needs
train.obj/val.objfiles. - The user wants to train or fine-tune zi2zi's conditional adversarial U-Net.
- The user wants to run generator inference, interpolate between style labels, create transition frames/GIFs, or export generator weights.
- The user needs help debugging legacy Python 2.7, TensorFlow 1.x, Pillow, scipy image I/O, checkpoint, label, or experiment-layout problems in a zi2zi workflow.
Avoid this skill when
- The task is a general pix2pix, CycleGAN, diffusion, OCR, or font-rendering question with no zi2zi command/API surface.
- The user is asking to port zi2zi to TensorFlow 2/PyTorch; this skill can explain the legacy model but does not provide a porting recipe.
- The user needs a modern packaged library with importable Python APIs; zi2zi is primarily a script-based repository, not an installable distribution.
Runtime expectations
For freshness checks, read repo provenance before using this skill against a different zi2zi checkout.
- zi2zi is legacy Python 2.7 + TensorFlow 1.x code. Do not assume Python 3,
TensorFlow 2, or current
scipy.miscAPIs work with the original scripts. - Practical training and checkpoint inference were designed for CUDA/cuDNN, but full training is long-running and should not be launched without explicit user approval, data, output location, and hardware budget.
- No pretrained checkpoint or font files are bundled in this skill. When a task
needs real training or inference, confirm the user has source/target fonts,
packaged
.objdata, or a TensorFlow checkpoint. - The bundled scripts in this skill are safe Python 3 planners/inspectors. They help construct commands and validate artifacts; they are not replacements for zi2zi's full TensorFlow model implementation.
Public install and verification direction
Use an isolated legacy environment for the original zi2zi scripts. A typical Conda direction is:
conda create -n zi2zi-legacy python=2.7 pip
conda install -n zi2zi-legacy tensorflow-gpu=1.15 scipy imageio pillow functools32
Then verify parser/import readiness from a zi2zi checkout:
python font2img.py --help
python package.py --help
python train.py --help
python infer.py --help
python export.py --help
Do not run long training or checkpoint inference until the user confirms data, checkpoint paths, GPU/runtime readiness, and output locations.
Route map
| If the task is about... | Read |
|---|---|
Rendering paired glyph images, choosing CJK/custom charsets, label prefixes, packaging JPGs into .obj, or inspecting packaged data |
data-preparation |
Training or fine-tuning, experiment directories, losses, label shuffling, freeze_encoder, fine_tune, checkpoints, samples, or model architecture |
training-and-model |
| Generator inference, random style IDs, interpolation frames/GIFs, output image names, checkpoint restore, or generator-only export | inference-and-export |
| End-to-end flow across all stages | workflow overview |
| Legacy dependency and backend compatibility | compatibility |
| Cross-cutting failures that affect multiple stages | troubleshooting |
Standard end-to-end flow
- Use
font2img.pysemantics to render source/target glyph pairs. The target glyph occupies the left half of each JPG, the source glyph the right half, and the filename prefix stores the style label. - Use
package.pysemantics to createtrain.objandval.obj, each a stream of pickled(label, image_bytes)records. - Place those files under an experiment data directory, normally
experiment/data/train.objandexperiment/data/val.obj. - Train with
train.py, which creates per-experiment checkpoint, log, and sample directories and saves checkpoints under a batch-size-specific name. - Run
infer.pyfrom a trained generator checkpoint, optionally interpolating style embeddings and compiling frames into a GIF. - Use
export.pyonly when a generator-only checkpoint is needed for later inference or transfer.
Useful bundled helpers
- Run scripts/zi2zi_smoke_plan.py when you need a safe checklist of zi2zi files, dependencies, and native smoke commands for a user's checkout.
- Use the data-preparation planners before writing or executing destructive preprocessing commands.
- Use the training and inference planners to validate paths, labels, and command flags before launching long TensorFlow jobs.
Verification baseline
During skill construction, safe checks covered Python 2.7 dependency imports,
all five original script --help parsers, and a CPU-hidden TensorFlow 1.15
UNet graph build. Full CUDA training and checkpoint-backed inference/export
were intentionally not run because they require user-provided fonts/data or
checkpoints and a legacy CUDA runtime budget. Preserve that distinction when
answering runtime-readiness questions.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).