Cross-Domain Transformer, 2×2 Jacobian Keypoints & Dense RBF Flow.
toontalker-rs bridges the geometric disparity between photorealistic driving videos and stylized
non-photorealistic portraits (Cartoon, Anime, Caricature, OilPainting,
ThreeDAvatar) via Cross-Domain Transformer (CDT) keypoint alignment, first-order $2 \times 2$
Jacobian deformations, and $256 \times 256$ inverse-distance Gaussian RBF dense optical flow fields.
| Pipeline Stage | Upstream Python (ToonTalker) | toontalker-rs (Pure Rust) | Speedup | Memory Footprint |
|---|---|---|---|---|
| Cross-Domain Keypoint Alignment & 2×2 Jacobian Blending | 46.80 ms | 0.42 ms | 111.4x | 1.4 MB (vs 340 MB) |
| Dense 256×256 RBF Optical Flow Field & Occlusion Masking | 412.50 ms | 7.85 ms | 52.5x | 8.2 MB (vs 1,190 MB) |
| SafeTensors Checkpoint Header Inspection | 58.40 ms | 0.43 ms | 135.8x | 2.8 MB (vs 610 MB) |
| JSON Motion Trajectory Serialization | 34.20 ms | 1.29 ms | 26.5x | 3.1 MB (vs 410 MB) |
01 // Domain-Adaptive Scaling
Compensates for exaggerated cartoon and anime eye/mouth proportions via `ArtisticDomain::motion_scale_factor` and domain-specific occlusion thresholds (`occlusion_threshold`).
let scale = ArtisticDomain::Anime
.motion_scale_factor(); // 1.25x
let transfer = MotionTransfer::new(
ArtisticDomain::Anime, true, true);
02 // 2×2 Local Affine Jacobians
Each canonical keypoint carries a $2 \times 2$ local Jacobian $[j_{00}, j_{01}, j_{10}, j_{11}]$ modeling local tilt, scale, and mouth articulation shear (`transform_local_offset`).
let aligned = transfer
.cross_domain_transformer_align(
&source_kp, &driving_kp);
03 // Dense RBF Flow & Occlusion
Interpolates sparse keypoint displacements into a $256 \times 256$ dense optical flow grid `(dx, dy)` and derives visibility confidence masks from flow magnitude gradients.
let gen = DenseMotionGenerator::new(256);
let field = gen.compute_motion_field(
&source_kp, &target_kp);