PitchHut
Log in / Sign up
Face Anonymization Made Simple
22 views
Effortlessly mask identities while preserving crucial facial details.
Pitch

Face Anonymization Made Simple is an advanced technique that allows for effective identity masking while maintaining original facial expressions and background elements. Ideal for real-world applications, this project seamlessly blends anonymized faces into photographs for enhanced privacy without losing context.

Description

Face Anonymization Made Simple is a cutting-edge implementation developed for the WACV 2025 conference. This project provides a robust solution for face anonymization, ensuring original facial expressions, head positions, eye directions, and background elements are preserved while effectively masking identities. The result is a seamless blend of anonymized faces within the original photographs, ideal for various real-world applications.

Key Features

  • Preserve Identity Elements: The technique maintains crucial details of the original image while anonymizing faces, ensuring that the background and facial expressions remain intact.

  • Versatile Usability: Whether you have a single aligned face or multiple unaligned faces, our method adapts effectively to your needs.

  • Easy Integration: Built upon the popular Diffusers framework, our project enables straightforward integration into your existing workflows.

Usage Examples

Anonymizing Images with a Single Aligned Face

An anonymized version of an image can be created using the following code snippet. The image should contain a single face aligned similarly to those in the FFHQ or CelebA-HQ datasets:

# get an input image for anonymization
original_image = load_image("my_dataset/14795.png")

# generate an image that anonymizes faces
anon_image = pipe(
    source_image=original_image,
    conditioning_image=original_image,
    num_inference_steps=200,
    guidance_scale=4.0,
    generator=generator,
    anonymization_degree=1.25,
).images[0]
anon_image.save("anon.png")

Anonymizing Images with Unaligned Faces

To create an anonymized version for images with one or more unaligned faces, use this approach:

import face_alignment
from utils.anonymize_faces_in_image import anonymize_faces_in_image

# get an input image for anonymization
original_image = load_image("my_dataset/friends.jpg")

# SFD (likely best results, but slower)
fa = face_alignment.FaceAlignment(
    face_alignment.LandmarksType.TWO_D, face_detector="sfd"
)

# generate an image that anonymizes faces
anon_image = anonymize_faces_in_image(
    image=original_image,
    face_alignment=fa,
    pipe=pipe,
    generator=generator,
    face_image_size=512,
    num_inference_steps=25,
    guidance_scale=4.0,
    anonymization_degree=1.25,
)
anon_image.save("anon.png")

Swapping Faces Between Two Images

The tool can also swap faces between two images with ease:

# get source and conditioning (driving) images for face swap
source_image = load_image("my_dataset/00482.png")
conditioning_image = load_image("my_dataset/14795.png")

# generate an image that swaps faces
swap_image = pipe(
    source_image=source_image,
    conditioning_image=conditioning_image,
    num_inference_steps=200,
    guidance_scale=4.0,
    generator=generator,
    anonymization_degree=0.0,
).images[0]
swap_image.save("swap.png")

Additional Resources

For further exploration, we provide a detailed demo.ipynb, which walks you through these functionalities step-by-step.

Acknowledgements

This project is built upon the foundations of the Diffusers framework. The face extractor functionality has been adapted from DeepFaceLab.

Explore the capabilities of face anonymization and experience a versatile approach to privacy and data protection in images.