# FaceFlow
**Facial Recognition Workflow Engine for Facial Expression & Emotive Processing**
FaceFlow is a lightweight, modular Python framework that lets you build, run, and manage custom pipelines for face detection, landmark extraction, emotion recognition, and more. It supports images and real-time video, with first-class integration for **MediaPipe** (fast detection/landmarks) and **DeepFace** (state-of-the-art emotion, age, gender, and identity analysis).
---
## ✨ Features
- **Workflow Engine**: Chain reusable steps (linear or easily extendable to DAGs)
- **Multi-Face Support**: Handles multiple faces per frame/image
- **Emotive Processing**: Dominant emotions + confidence scores (`happy`, `sad`, `angry`, `surprised`, `neutral`, `fear`, `disgust`)
- **Backends**:
- MediaPipe (real-time face detection + 468 landmarks)
- DeepFace (emotion + facial attribute analysis, supports MediaPipe detector)
- **Input Flexibility**: File paths, NumPy arrays (OpenCV), webcam, or uploaded files
- **API Ready**: FastAPI endpoints for easy integration
- **Extensible**: Add custom steps (e.g., Py-Feat for Action Units, your own ML models, identity DB)
- **Production Friendly**: Logging, error handling, video support
---
## 📦 Installation
```bash
# Clone or download the project
git clone <your-repo-url>
cd faceflow
# Install dependencies
pip install -r requirements.txt
# Optional: Advanced expression analysis
pip install py-featCore Dependencies (in requirements.txt):
opencv-pythonmediapipedeepfacefastapi,uvicornnumpy
import cv2
from faceflow.core.engine import FaceFlowEngine
from faceflow.core.workflow import Workflow
from faceflow.steps.loader import LoadImageStep
from faceflow.steps.detection import MediaPipeFaceDetector
from faceflow.steps.emotion import DeepFaceEmotionAnalyzer
# Create and register workflow
engine = FaceFlowEngine()
wf = (Workflow("basic_emotion")
.add_step(LoadImageStep())
.add_step(MediaPipeFaceDetector())
.add_step(DeepFaceEmotionAnalyzer(detector_backend="mediapipe")))
engine.register_workflow(wf)
# Run
image = cv2.imread("tests/sample_face.jpg")
result = engine.execute("basic_emotion", {"image": image})
print(f"Detected {result.get('num_faces')} face(s)")
for emotion in result.get("emotions", []):
print(f"Dominant emotion: {emotion['dominant_emotion']}")uvicorn faceflow.api.main:app --reloadTest with curl or Postman:
curl -X POST "http://127.0.0.1:8000/analyze" \
-F "file=@sample_face.jpg" \
-F "workflow=basic_emotion"faceflow/
├── faceflow/
│ ├── core/ # Engine, Workflow, Step base
│ ├── steps/ # Reusable pipeline steps
│ ├── utils/
│ ├── api/ # FastAPI endpoints
│ └── cli.py
├── examples/ # Usage demos
├── tests/
├── requirements.txt
└── README.md
Key steps available:
LoadImageStepMediaPipeFaceDetectorMediaPipeFaceMesh(landmarks)DeepFaceEmotionAnalyzer
See examples/video_emotion_workflow.py for webcam or video file processing with frame-by-frame analysis and on-screen overlays.
from faceflow.core.step import Step
class MyCustomStep(Step):
def process(self, data):
# Your logic here (e.g., head pose, spoof detection)
return datacustom_wf = Workflow("my_workflow").add_step(...)...
engine.register_workflow(custom_wf)- angry
- fear
- neutral
- sad
- disgust
- happy
- surprise
- Fork the repo
- Create a feature branch
- Add tests for new steps
- Submit a Pull Request
We welcome new backends, visualization steps, and documentation improvements.
MIT License – see file.
Made with ❤️ for computer vision & affective computing enthusiasts.
Questions? Open an issue or reach out!
Copy the content above into `README.md` at the root of your project. It is professional, comprehensive, and ready for GitHub or internal use. Let me know if you want a version with badges, screenshots, or more sections!