Face-Anonymiser is a Python-based application designed to anonymize faces in real-time video streams using computer vision and deep learning techniques. It leverages MediaPipe for facial landmark detection and OpenCV for video processing. The application allows users to replace detected faces with avatars, which can be switched using hand-swipe gestures. The project also includes notebook-based workflows for advanced avatar generation and integration with ComfyUI, a UI for generative models.
- Real-time Face Detection using MediaPipe Face Mesh
- Avatar Replacement with gesture-based switching
- Gesture Recognition via MediaPipe Hands
- Avatar Gallery loaded from
face-avatarsdirectory - Video Processing with OpenCV
- Advanced workflows in Jupyter Notebooks for avatar/model generation
- Flow Matching Enhancement: Incorporates a generative model for flow matching, enabling seamless and realistic blending of avatars onto faces by learning pixel-wise correspondences and transformations. This improves the quality and naturalness of anonymization, especially in dynamic scenes.
anon.py: Main application scriptface_mesh.py: Face mesh logicface_mesh.ipynb: Notebook for face mesh experimentationface-avatars/: Avatar imagesnotebooks/comfyui_colab_with_manager.ipynb: Advanced avatar/model workflowsREADME.md: Project documentation
- Facial Landmark Detection (468 points per frame)
- Delaunay Triangulation for warping avatars
- Gesture Detection for avatar switching
- Image Warping using OpenCV and NumPy
- Flow Matching Generative Model: Learns and applies pixel-wise flow fields to blend avatars onto faces, enhancing realism and adaptability to facial movements.
- Initialization: Load models and avatars
- Video Capture: Start webcam stream
- Face Detection & Landmark Extraction
- Gesture Recognition for avatar switching
- Avatar Warping & Replacement
- Flow Matching: Apply generative flow matching model to blend avatars onto faces for improved realism
- Display Output: Show anonymized video
- Advanced Avatar Generation (optional, via notebooks)
- Python 3.12+
- OpenCV (
cv2) - MediaPipe (
mediapipe) - NumPy (
numpy) - Torch (
torch,torchvision) - Pillow (
PIL) - Matplotlib
- Other packages for avatar/model generation:
manifold3d,pycollada,svg-path, etc. - Jupyter Notebooks
- ComfyUI
- Flow Matching Model: Deep learning model for pixel-wise flow estimation and blending (can be implemented in PyTorch or TensorFlow)
face-avatars/character1.jpgface-avatars/character2.png- Supports more avatars as needed
- Avatar Generation: Custom avatars via generative models in notebooks
- Model Management: ComfyUI integration
- Cloud/Colab Support: Notebooks for cloud workflows
- Flow Matching: Easily extendable to use state-of-the-art generative flow models for improved anonymization quality
Face-Anonymiser is a modular, extensible tool for anonymizing faces in video streams using avatars. It combines real-time computer vision, gesture recognition, generative AI workflows, and now flow matching for enhanced realism, making it suitable for privacy applications, creative projects, and research.