# joevenner/facerecognition-gui-app architecture

> Architecture diagram of the GitHub repository joevenner/facerecognition-gui-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joevenner/facerecognition-gui-app
- Repository: https://github.com/joevenner/facerecognition-gui-app

## Overview

##### Project Type and Purpose
- This is a Python-based desktop GUI application for face recognition. Its core functions include collecting face data, training face classifiers, and performing real-time face detection/recognition. Additional features incorporate age, gender, and emotion detection.
- The README indicates that the application includes multiple workflows (home page, add user, capture and train, recognition) that interact through the GUI.

##### File Structure
- Key Files:
- “app-gui.py”: Likely the main entry point for launching the GUI.
- “create_dataset.py” and “create_classifier.py”: Used for gathering face data and building/training classifiers.
- “predict.py”, “gender_prediction.py”, and “Detector.py”: Handle recognition, gender prediction, and face detection.
- “data/”: Contains configuration and model files (e.g., Haar cascades, Caffe models, prototxt files) for age, gender, and perhaps emotion detection.
- Other Supporting Files:
- “nameslist.txt”, “face_detection.log”: Likely used for logging user data or tracking detection results.
- “requirements.txt”: Lists dependencies (e.g., OpenCV, possibly TKinter or another GUI framework).
- The presence of clusters like “data/classifiers” suggests that classifiers are segregated by user or method (like “ngoc”, “tho”, “tho1”).

##### Defining the Main Components and Their Relationships
- GUI/Presentation Layer:
- Component: “app-gui.py”
- Role: Provides the user interface showing home page, add user page, capture page, and recognition results (with separate UI windows for webcam and additional detection outputs).
- Data Acquisition & Preprocessing:
- Components: “create_dataset.py”, “data” folder (includes models, captured images, etc.)
- Role: Handle face capture from the webcam, preprocessing images for classifier training.
- Classifier Training Module:
- Components: “create_classifier.py”, “data/classifiers/…”
- Role: Train the face classifier based on captured data; manage storage, loading, and updating of model files.
- Detection & Prediction Modules:
- Components: “predict.py”, “gender_prediction.py”, “Detector.py”
- Role: Execute the face detection, age and gender predictions, and potentially emotion detection in real-time.
- Model and Configuration Repository:
- Component: “data/”
- Role: Contains all pre-trained models, configuration files (e.g., “age_deploy.prototxt”, “haarcascade_frontalface_default.xml”), and classifier files used by the detection modules.

##### Architectural Patterns and Design Principles
- Modularity: The project clearly separates data capture, training, and detection logic into distinct Python scripts.
- Single Source of Data: The “data” directory serves as a central resource repository for models, configurations, and classifiers.
- Reusability: With dedicated scripts for specific tasks (face detection, gender prediction, classifier creation), functionalities are decoupled and reusable across different application flows.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% GUI Layer
    AppGUI["App GUI (Home, Add User, Capture & Train, Recognition)"]:::gui

    %% Data Acquisition Module
    DataAcq["Data Acquisition (create_dataset.py)"]:::acquisition

    %% Classifier Training Module
    Classifier["Classifier Training (create_classifier.py)"]:::training
    Classifiers["Trained Classifiers (data/classifiers)"]:::repository

    %% Model and Config Repository
    ModelRepo["Model & Config Repository (data/)"]:::repository

    %% Detection & Prediction Modules Subgraph
    subgraph "Detection & Prediction Modules"
      direction TB
      Predict["predict.py"]:::detection
      Gender["gender_prediction.py"]:::detection
      Detector["Detector.py"]:::detection
    end

    %% Connections between components
    AppGUI -->|"capture_face"| DataAcq
    DataAcq -->|"prepare_data"| Classifier
    Classifier -->|"store_model"| Classifiers

    AppGUI -->|"trigger_recognition"| Predict
    AppGUI -->|"trigger_recognition"| Gender
    AppGUI -->|"trigger_recognition"| Detector

    Predict -->|"load_model"| ModelRepo
    Gender -->|"load_model"| ModelRepo
    Detector -->|"load_model"| ModelRepo

    %% Click Events
    click AppGUI "https://github.com/joevenner/facerecognition-gui-app/blob/master/app-gui.py"
    click DataAcq "https://github.com/joevenner/facerecognition-gui-app/blob/master/create_dataset.py"
    click Classifier "https://github.com/joevenner/facerecognition-gui-app/blob/master/create_classifier.py"
    click Classifiers "https://github.com/joevenner/facerecognition-gui-app/tree/master/data/classifiers"
    click Predict "https://github.com/joevenner/facerecognition-gui-app/blob/master/predict.py"
    click Gender "https://github.com/joevenner/facerecognition-gui-app/blob/master/gender_prediction.py"
    click Detector "https://github.com/joevenner/facerecognition-gui-app/blob/master/Detector.py"
    click ModelRepo "https://github.com/joevenner/facerecognition-gui-app/tree/master/data/"

    %% Styles
    classDef gui fill:#aqua,stroke:#000,stroke-width:2px;
    classDef acquisition fill:#ccffcc,stroke:#000,stroke-width:2px;
    classDef training fill:#ffffcc,stroke:#000,stroke-width:2px;
    classDef detection fill:#ffccff,stroke:#000,stroke-width:2px;
    classDef repository fill:#cce5ff,stroke:#000,stroke-width:2px;
```
