Professional 3D face reconstruction for ComfyUI using the Pixel3DMM method
Transform 2D face images into detailed 3D models with state-of-the-art neural networks, FLAME parametric models, and advanced optimization techniques.
- π Complete 3D Face Reconstruction: From single images to detailed 3D meshes
- π₯ FLAME Model Integration: Industry-standard parametric face model
- πΊοΈ UV Coordinate Prediction: High-quality texture mapping
- π Surface Normal Estimation: Detailed geometric surface information
- β‘ Real-time Optimization: Interactive parameter refinement
- π¦ Multiple Export Formats: OBJ, PLY, STL mesh export
- ποΈ User-Friendly Interface: Intuitive ComfyUI integration
- Installation
- Quick Start
- Node Reference
- Workflow Examples
- Troubleshooting
- Advanced Usage
- Contributing
- License
- ComfyUI: Latest version installed and working
- Python: 3.9 or higher
- PyTorch: 2.0 or higher (CPU or CUDA)
- System Memory: 8GB+ RAM recommended
- Open ComfyUI Manager
- Search for "Pixel3DMM"
- Click "Install"
- Restart ComfyUI
-
Clone the repository:
cd ComfyUI/custom_nodes/ git clone https://github.com/your-repo/comfyui-pixel3dmm.git -
Install dependencies:
cd comfyui-pixel3dmm pip install -r requirements.txt -
Restart ComfyUI
- Download the latest release from Releases
- Extract to
ComfyUI/custom_nodes/comfyui-pixel3dmm/ - Install dependencies:
pip install -r requirements.txt - Restart ComfyUI
- Load an image using ComfyUI's
Load Imagenode - Add Pixel3DMM Loader node and configure model path
- Connect Face Reconstructor node to process the image
- Add Mesh Exporter to save your 3D model
[Load Image] β [Pixel3DMM Loader] β [Face Reconstructor 3D] β [Mesh Exporter]
{
"workflow": "basic_reconstruction",
"nodes": [
{"type": "LoadImage", "inputs": {"image": "face_photo.jpg"}},
{"type": "Pixel3DMMLoader", "inputs": {"model_path": "models/pixel3dmm.pth"}},
{"type": "FaceReconstructor3D", "inputs": {"quality": "balanced"}},
{"type": "MeshExporter", "inputs": {"format": "obj", "filename": "face_3d"}}
]
}Purpose: Load and initialize Pixel3DMM models
Inputs:
model_path(STRING): Path to model filedevice(CHOICE): auto/cpu/cudaprecision(CHOICE): fp32/fp16config_override(STRING): JSON config overrides
Outputs:
model(PIXEL3DMM_MODEL): Loaded model containerstatus(STRING): Loading status message
Usage:
# Basic usage
model_path = "models/pixel3dmm_model.pth"
device = "auto" # Automatically detect GPU/CPU
precision = "fp32" # Use fp16 for faster inference on GPUPurpose: Complete 3D face reconstruction from images
Inputs:
model(PIXEL3DMM_MODEL): Loaded model from Pixel3DMM Loaderimage(IMAGE): Input face imagereconstruction_quality(CHOICE): fast/balanced/highoptimize_flame(BOOLEAN): Enable parameter optimizationoptimization_steps(INT): Number of optimization iterationslearning_rate(FLOAT): Optimization learning rate
Outputs:
rendered_face(IMAGE): Rendered 3D face viewflame_parameters(FLAME_PARAMS): FLAME model parametersmesh_data(MESH_DATA): 3D mesh datastatus(STRING): Reconstruction status
Quality Settings:
- Fast: Quick reconstruction, lower quality
- Balanced: Good quality-speed tradeoff (recommended)
- High: Best quality, slower processing
Purpose: Predict UV coordinates for texture mapping
Inputs:
model(PIXEL3DMM_MODEL): Loaded modelimage(IMAGE): Input face imageoutput_resolution(CHOICE): 256/512/1024uv_smoothing(FLOAT): Smoothing amount (0.0-1.0)confidence_threshold(FLOAT): Confidence threshold (0.0-1.0)
Outputs:
uv_map(IMAGE): UV coordinate visualizationuv_coordinates(UV_COORDS): Raw UV coordinate datastatus(STRING): Prediction status
Purpose: Predict surface normals for geometric detail
Inputs:
model(PIXEL3DMM_MODEL): Loaded modelimage(IMAGE): Input face imageoutput_resolution(CHOICE): 256/512/1024normal_space(CHOICE): camera/worldnormal_smoothing(FLOAT): Smoothing amount (0.0-1.0)enhance_details(BOOLEAN): Enable detail enhancement
Outputs:
normal_map(IMAGE): Normal map visualizationnormal_vectors(NORMALS): Raw normal vector datastatus(STRING): Prediction status
Purpose: Optimize FLAME parameters using geometric constraints
Inputs:
model(PIXEL3DMM_MODEL): Loaded modelimage(IMAGE): Input face imageinitial_params(FLAME_PARAMS): Initial FLAME parametersoptimization_steps(INT): Number of optimization stepsuv_coordinates(UV_COORDS): Optional UV constraintssurface_normals(NORMALS): Optional normal constraintslearning_rate(FLOAT): Optimization learning rateuv_weight(FLOAT): UV loss weightnormal_weight(FLOAT): Normal loss weightregularization_weight(FLOAT): Regularization weight
Outputs:
optimized_params(FLAME_PARAMS): Optimized parametersmesh_data(MESH_DATA): Optimized mesh datastatus(STRING): Optimization status
Purpose: Export 3D meshes to various formats
Inputs:
mesh_data(MESH_DATA): 3D mesh data to exportoutput_format(CHOICE): obj/ply/stlfilename(STRING): Output filenameoutput_directory(STRING): Output directory pathinclude_textures(BOOLEAN): Include texture coordinatesscale_factor(FLOAT): Mesh scaling factorcenter_mesh(BOOLEAN): Center mesh at origin
Outputs:
file_path(STRING): Path to exported filestatus(STRING): Export status
[Load Image] β [Pixel3DMM Loader] β [Face Reconstructor 3D] β [Mesh Exporter]
Use Case: Quick 3D face model from photo Quality: Balanced Time: ~30 seconds
[Load Image] β [Pixel3DMM Loader] β [Face Reconstructor 3D]
β
[UV Predictor] β [FLAME Optimizer] β [Mesh Exporter]
β β
[Normal Predictor] ----
Use Case: Professional-quality 3D reconstruction Quality: High Time: ~2-5 minutes
[Load Image Batch] β [Pixel3DMM Loader] β [Face Reconstructor 3D] β [Mesh Exporter Batch]
Use Case: Process multiple faces Quality: Configurable Time: Varies by batch size
Solution:
- Check model path is correct
- Download required model files
- Ensure models are in the correct directory
Solutions:
- Switch to CPU: Set device to "cpu"
- Use FP16: Set precision to "fp16"
- Reduce image resolution
- Close other GPU applications
Solutions:
- Install dependencies:
pip install -r requirements.txt - Restart ComfyUI completely
- Check Python environment
Solutions:
- Use higher quality settings
- Enable FLAME optimization
- Ensure good input image quality
- Check lighting and face visibility
Solutions:
- Use GPU if available
- Enable FP16 precision
- Use "fast" quality setting
- Reduce optimization steps
- GPU Usage: Always use GPU when available for 10x+ speedup
- Image Size: 512x512 is optimal, larger images don't improve quality significantly
- Batch Size: Process multiple images together for efficiency
- Memory: Close other applications to free up GPU memory
- Check the logs: ComfyUI console shows detailed error messages
- GitHub Issues: Report bugs and request features
- Community: Join our Discord for support and discussions
- Documentation: Check our wiki for advanced tutorials
# Train custom UV predictor
from pixel3dmm.training import UVTrainer
trainer = UVTrainer(config)
trainer.train(dataset_path="path/to/uv_data")# Use nodes programmatically
from comfyui_pixel3dmm import Pixel3DMMLoader, FaceReconstructor3D
loader = Pixel3DMMLoader()
model, status = loader.load_model("models/pixel3dmm.pth")
reconstructor = FaceReconstructor3D()
result = reconstructor.reconstruct_face(model, image)Create config.json for custom settings:
{
"model": {
"encoder_backbone": "vit_base_patch14_dinov2.lvd142m",
"embedding_dim": 128,
"flame_dim": 101
},
"optimization": {
"max_steps": 200,
"learning_rate": 0.01,
"convergence_threshold": 1e-6
}
}- Paper: Pixel3DMM: Generating 3D Representations from Multi-view Images
- FLAME Model: Official FLAME repository
- ComfyUI: ComfyUI documentation
- Tutorials: Video tutorials playlist
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
git clone https://github.com/your-repo/comfyui-pixel3dmm.git
cd comfyui-pixel3dmm
pip install -e .
pip install -r requirements-dev.txtpython -m pytest tests/
python tests/test_pixel3dmm_nodes.pyThis project is licensed under the MIT License - see the LICENSE file for details.
- Pixel3DMM Research Team: Original research and methodology
- FLAME Team: Parametric face model
- ComfyUI Community: Framework and inspiration
- PyTorch Team: Deep learning framework
If you use this work in your research, please cite:
@article{pixel3dmm2023,
title={Pixel3DMM: Generating 3D Representations from Multi-view Images},
author={Research Team},
journal={arXiv preprint arXiv:2023.xxxxx},
year={2023}
}Made with β€οΈ by the MCP Multi-Agent System
For support, please open an issue on GitHub or join our Discord community.