A powerful ControlNet-based system that enables precise control over individual facial features during face generation. Create entirely new synthetic faces by composing and manipulating 8 distinct facial components with parametric control over position, scale, and composition.
This project serves as a comprehensive template for bachelor students at the University of Bremen, where I supervise their theses. It provides a solid foundation for students to explore parametric face generation, test hypotheses, and build upon established best practices.
While designed for educational purposes, everyone is welcome to use, learn from, and contribute to this project.
Everything you need for precise face generation
Independently control 8 distinct facial features including eyes, nose, mouth, hair, and more. Adjust position, scale, and composition for complete creative freedom.
Mix and match features from different faces in your dataset. Create entirely new, synthetic faces with precise control over each component.
See immediate visual feedback as you compose masks. The intuitive GUI provides instant preview of your feature selections before generation.
Leverages BiSeNet for accurate facial parsing. Automatically segments faces into 19 regions, enabling precise feature extraction and manipulation.
Train on your own face datasets. Full control over training parameters, validation, and checkpoint management with accelerate support.
User-friendly Gradio interface for seamless face generation. Browse feature galleries, compose masks, and adjust generation parameters effortlessly.
Experience the power of parametric face generation
Scan and index facial feature masks from your dataset
Browse galleries and select features for each facial component
Real-time preview of combined masks before generation
Adjust seed, steps, and ControlNet scale for perfect results
From face images to generated faces in three simple steps
Use BiSeNet face parsing to generate semantic segmentation masks from your face images. The model automatically segments 19 facial regions, from which 8 features are selected.
python inference.py \
--model resnet34 \
--weight ./resnet34.pt \
--input ./faces \
--output ./dataset/output/resnet34
Fine-tune a ControlNet model on your face-mask pairs. The training script automatically handles multi-channel mask stacking, validation, and checkpoint management.
accelerate launch train.py \
--data_root ./dataset \
--output_dir ./trained_model \
--batch_size 4 \
--max_steps 50000
Launch the interactive GUI to compose and generate new faces. Select features, adjust parameters, and see results in real-time with instant visual feedback.
python face-mask/gui-inference.py \
--controlnet_dir ./trained_model/final_model \
--share
Built on proven diffusion model technology
Built with industry-standard tools and frameworks
Deep learning framework for model training and inference
Foundation model for high-quality image generation
Conditional control for precise guidance during generation
Face parsing model for semantic segmentation
Distributed training with multi-GPU support
Interactive web interface for user-friendly interaction
HuggingFace library for diffusion model pipelines
Text encoding with CLIP for prompt conditioning
Start generating faces in minutes
git clone https://github.com/danial-barazandeh/ControlNetFaceGenerator.git
cd controlnet-face-generator
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118
pip install diffusers transformers accelerate safetensors
pip install gradio opencv-python pillow matplotlib tqdm
Follow the detailed instructions in the README to generate masks with BiSeNet and train your ControlNet model.
Join the community and start creating parametric faces with precise control