Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

53 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎭 PersonaForge AI β€” High-Fidelity Video Face Swapping

PersonaForge AI Banner

⚑ The ultimate privacy-focused local video face transformation engine.

Privacy-First. GPU-Accelerated. 100% Local.

Python CUDA FastAPI Status License: MIT GitHub release


πŸ“Œ Table of Contents

  1. πŸ“– Overview
  2. ✨ Core Features
  3. πŸš€ Getting Started
  4. πŸ“½οΈ Transformation Showcase
  5. πŸ—οΈ System Architecture
  6. πŸ“Š Technical Benchmark: GPU vs. CPU
  7. πŸ” Validation & Realism Constraints
  8. πŸŽ›οΈ Slide Presentation Generator
  9. πŸ“ Project Architecture
  10. βš™οΈ Tuning Configurations
  11. πŸ‘€ About the Author

πŸ“– Overview

PersonaForge AI is an advanced computer vision engineering project designed to run high-fidelity face transformations entirely on local consumer hardware. By decoupling heavy AI dependencies and implementing a robust Hardware Abstraction Layer, the system dynamically schedules execution between GPU (CUDA-accelerated) and CPU branches.

This project is built for AI engineers, recruiters, and open-source contributors looking to explore high-throughput local inference pipelines without relying on external cloud APIs or exposing private media files.


✨ Core Features

  • πŸ”’ Privacy-First Operations: 100% offline. Zero tracking pixels, zero API calls, and zero external cloud uploads.
  • βš™οΈ Hardware-Aware Execution: A custom initialization engine that detects local environment bindings and dynamically routes frame arrays to CUDA execution providers or CPU fallbacks.
  • ⚑ In-Memory Streaming (RAM I/O): Bypasses standard disk-writing bottleneck loops by buffering frames in RAM and piping them directly to FFmpeg stdin via standard stream buffers.
  • πŸ“ˆ Facial Identity Consistency: Automatically computes the Cosine Similarity between the source identity embedding and every processed target frame face node to log identity drift statistics.
  • πŸ’¨ Kernelized Correlation Filter (KCF) Tracking: Reduces expensive facial detection calls (InsightFace inference loops) by 90% by using adaptive KCF tracking blocks on intermediate frames.

πŸš€ Getting Started

To install dependencies, download model weights, set up the FastAPI server, run the Streamlit dashboard, or profile execution providers, please refer to our step-by-step PersonaForge AI Getting Started Guide.


πŸ“½οΈ Transformation Showcase

Here is a demo loop showing the input and high-fidelity output alignment:

Transformation Showcase


πŸ—οΈ System Architecture

1. System Architecture Blueprint

The application is structured into decoupled frontend presentation, API gateway, and model runtime layers.

PersonaForge AI Architecture Diagram

2. Processing Pipeline process flow

The modular pipeline manages frame ingestion, boundary box extraction, model embedding, Poisson blending, and final audio MUXing.

PersonaForge AI Process Flow Diagram

Tip

Why KCF Face Tracking? running face detection models (InsightFace) on every frame is the primary CPU bottleneck. By introducing Kernelized Correlation Filters (KCF) to track boundary boxes across intermediate frames, we avoid calling the heavy detection networks on 9 out of 10 frames, increasing processing throughput by 90% on laptops.


πŸ“Š Technical Benchmark: GPU vs. CPU

Metric πŸ”₯ GPU Pipeline (High-Fidelity) πŸ’¨ CPU Pipeline (Optimized)
Primary Platform Workstations / Compute Servers Consumer Laptops / Prototyping
Max Target Resolution Original / 1080p / 4K 720p (Adaptive Downscale)
Enc. Audio MUX Bitrate 12 Mbps (High Fidelity) 6 Mbps (Web-Optimized)
Edge Blending Mode Poisson (SeamlessClone) Direct Feathered Alpha-Paste
Face Detection Loop Frame-by-Frame Precision KCF Tracker (1-in-10 detection)
Execution Performance ~40 seconds (10s video @ 30fps) ~110 seconds (10s video @ 30fps)

πŸ” Validation & Realism Constraints

To set realistic expectations, we track and report edge cases where face transformation fidelity may drift:

Scenario Success Rate System Pipeline Behavior
Centric Face Orientation 🟒 99% Perfect alignment, facial landmark match, and edge blending.
Extreme Profile Angle 🟑 70% Identity drifts if landmarks or eye vertices are occluded.
Low-Light / Film Grain 🟑 75% Minor boundary seams may become visible during Poisson cloning.
Rapid Head Motion πŸ”΄ 60% KCF tracker fallback triggers full InsightFace redetection.
Multi-Face Crowd Scenes 🟒 90% Configurable target selection indices (ordered by face area size).

πŸŽ›οΈ Slide Presentation Generator

The codebase includes an automated presentation slide generator utilizing Playwright. This tool compiles our CSS slide design template into 11 premium vertical presentation slides (designed at 1080x1350, exported at 4K-density 2160x2700 for maximum clarity).

To render the presentation:

  1. Initialize the virtual environment and install Playwright requirements (see docs/guide.md).
  2. Execute the python generator script:
    python scripts/generate_carousel.py
  3. Find the rendered slides in the outputs/carousel/ directory.

πŸ“‚ Project Architecture

  • pipelines/: Contains execution scripts pipeline_gpu.py (CUDA) and pipeline_cpu.py (CPU).
  • config/: Central parameter profiles config_cpu.py and config_gpu.py.
  • models/: model_manager.py handles model checks, folder creation, and auto-downloads.
  • utils/: Shared functions including the correlation tracking factory tracker_factory.py.
  • scripts/: Automation tools like generate_carousel.py for rendering social media carousel decks.

βš™οΈ Tuning Configurations

Fine-tune execution variables inside config/ profiles:

# config_cpu.py parameters
PROCESS_EVERY_N_FRAMES = 3   # Skip detection frames for performance
TARGET_HEIGHT = 720          # Downscale input target resolution
DET_SIZE = (320, 320)        # Bound detector inference size

# config_gpu.py parameters
USE_SEAMLESS_CLONE = True    # Enable high-fidelity Poisson cloning
BITRATE = "12M"              # Render export bitrate

πŸ‘€ Author & Contact


Himanshu Jadhav

Artificial Intelligence & Data Science Engineer

Passionate about computer vision, real-world localized model deployment, and high-performance pipeline architecture.

GitHub LinkedIn Portfolio Instagram



πŸ’– Acknowledgements

  • InsightFace for state-of-the-art 2D and 3D face analysis.
  • ONNX Runtime for high-performance localized neural network inference.
  • FastAPI Framework for serving our local endpoints.
  • FFmpeg for specialized video stream demuxing and encoding.
  • OpenCV for pixel-level frame manipulation and correlation tracking.
  • The open-source computer vision community.

PersonaForge AI β€” Engineering High-Fidelity Identity

About

A fully local, GPU-accelerated AI face swapping system with FastAPI, ONNX Runtime, and a modular processing pipeline. Privacy-first, offline, and optimized for high-performance image and video face transformation.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages