This repository contains the code for the paper LDFA: Latent Diffusion Face Anonymization for Self-driving Applications.
- Modifications to Dockerfile for integrating xformers, k-diffusion, taming-transformers and CodeFormer to Automatic1111.
- Additional bash scripts to setup the environment and running detection & anonymization.
- Docker Compose V2. See Diff between V1 and V2. Install
- NVIDIA Container Toolkit
bash setup_requirements.sh # Downloads stable diffusion weights & nvidia-container-toolkit
bash setup_compose_env.sh # Sets the container variables
After you run setup_requirements.sh
and setup_compose_env.sh
, you can start the docker instances with docker compose up
.
The script will look for all images with the given extension in the provided root folder. Make sure you are using bash
to execute the scripts.
Once the docker container is running you can generate masks with:
bash generate_masks.sh
and anonymize the detected faces using:
bash anonymize.sh
The dockerfile is used to start container which runs the Automatic1111 web UI for stable diffusion. LDFA uses the API to conveniently use a stable diffusion model for the anonymization of human faces.
detect_faces.py
- This script uses RetinaFace to detect faces on a given dataset.ldfa_face_anon.py
- This script implements the LDFA anonymization method.simple_face_anon.py
- This script implements the naive anonymization methods cropping, gaussian noise and pixelaziation which are applied on detected faces.
setup_requirements.sh
- Downloadsstable-diffusion-2-inpainting
weights from HuggingFace, saves it atmodels/stable-diffusion
with the namelast.ckpt
.setup_compose_env.sh
- Creates.env
which includes port, directories (input, output) and image extension.generate_masks.sh
- Runsdetect_faces.py
in the container.anonymize.sh
- Runsldfa_face_anon.py
in the container.
If you are using LDFA in your research, please consider to cite us.
@InProceedings{Klemp_2023_CVPR,
author = {Klemp, Marvin and R\"osch, Kevin and Wagner, Royden and Quehl, Jannik and Lauer, Martin},
title = {LDFA: Latent Diffusion Face Anonymization for Self-Driving Applications},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops},
month = {June},
year = {2023},
pages = {3198-3204}
}