CoolFace
Apppublic

precison9/avatar-animation-pipeline

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
App README

๐ŸŽญ Video-Driven Avatar Animation Pipeline

Production-quality system that captures real human facial performance from video and retargets it onto a stylized avatar.

Architecture

Input Video (MP4, front-facing, well-lit)
    โ”‚
    โ–ผ
[1] Face Detection โ†’ OpenCV Haar Cascade (CPU, no GPU)
    โ”‚
    โ–ผ
[2] 68 Landmark Extraction โ†’ eyes, brows, nose, mouth, jaw
    โ”‚
    โ–ผ
[3] Head Pose + Expression Analysis
    โ”‚
    โ–ผ
[4] Temporal Smoothing (windowed averaging)
    โ”‚
    โ–ผ
[5] Piecewise Affine Warping โ†’ Delaunay triangular mesh deformation
    โ”‚
    โ–ผ
[6] Video Render โ†’ MP4 at 1080p/720p

Key Features

  • โ€”Pure CPU โ€” No GPU, no MediaPipe GL dependencies, works everywhere
  • โ€”68-point face model โ€” Industry standard, compatible with Blender/UE
  • โ€”Delaunay mesh warping โ€” Piecewise affine transforms for smooth deformation
  • โ€”Temporal smoothing โ€” Eliminates jitter, preserves natural timing
  • โ€”Canonical landmark fallback โ€” Works with cartoon/drawn avatars (no face detection needed)
  • โ€”Procedural avatar generation โ€” Build characters with color pickers if no reference image

Usage

  1. 1.Upload Input Video โ€” Front-facing speaker, good lighting (the motion source)
  2. 2.Upload Avatar Image OR customize procedural avatar with colors/hair/expression
  3. 3.Click Preview Avatar to see the character
  4. 4.Adjust Expression Exaggeration (1.2 = slightly more animated than source)
  5. 5.Click Process Video โ€” wait 1-2 min per minute of footage
  6. 6.Download: animated video + motion data JSON + Blender import script

Pipeline Parameters

ParameterRangeDefaultEffect
Expression Exaggeration0.5โ€“3.01.2Amplify facial movements
Temporal Smoothing1โ€“10 frames3Higher = smoother, lower = more responsive
Output Resolution720p/1080p/Square/Vertical1080pFinal dimensions

Limitations

  • โ€”Lip sync uses video mouth shapes, not audio phonemes. For audio-driven precision, add a dedicated module (e.g., Rhubarb, Wav2Lip).
  • โ€”No full body โ€” face/head only. Add DWPose or MediaPipe Holistic for shoulders.
  • โ€”No audio on HF Spaces (ffmpeg not available). Run locally for audio.
  • โ€”Haar detection can miss faces in poor lighting or extreme angles. Use front-facing, well-lit footage.

Tech Stack

  • โ€”Python 3.10+, OpenCV 4.8+, NumPy, Gradio 6
  • โ€”No deep learning models, no GPU required
  • โ€”Optional: FFmpeg for audio extraction

Local Development

bash
pip install -r requirements.txt
python app.py

Extending

EnhancementApproach
Audio lip syncAdd phoneme detection โ†’ viseme mapping
3D rotationMediaPipe Face Mesh (requires GPU/GL)
Full bodyDWPose or MediaPipe Holistic
Neural renderingReplace warping with LivePortrait
Style transferAnime/cartoon filter for non-illustrated avatars