# falcon97/celeba-face-classification architecture

> Architecture diagram of the GitHub repository falcon97/celeba-face-classification, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/falcon97/celeba-face-classification
- Repository: https://github.com/falcon97/celeba-face-classification

## Overview

##### Project type and purpose
- This is a machine-learning / neural-network project whose goal is to train and evaluate two models (a single‐layer neural network and a deep neural network) on the CelebA face dataset (binary classification: glasses vs. no-glasses).
- Key artifacts:
- deep_nn.py – implements and runs a multi‐layer network
- single_layer_nn.py – implements and runs a perceptron-style network
- face_all.pickle – preprocessed image data in serialized form

##### Main components
a. Data Source
- face_all.pickle (serialized dataset)
b. Data Pipeline
- Loading module (unpickle, reshape, normalize)
- (Optional) train/test split logic
c. Model Definitions
- SingleLayerNN component
- DeepNN component
d. Training / Evaluation Engine
- Training loop (forward pass, backprop, parameter updates)
- Evaluation (compute loss, accuracy metrics)
e. External Libraries
- NumPy (array ops), pickle
f. Outputs
- Trained model parameters (in-memory or saved)
- Performance metrics (printed/logged)

##### Relationships & data flow
- Data file → Data loader → Preprocessed arrays
- Preprocessed arrays ↔ Model component (forward/backward)
- Model component → Updated parameters (training)
- Trained model → Evaluation module → Metrics → Console/log

##### Architectural patterns & design principles
- Pipeline pattern: clear separation of concerns (I/O vs. preprocessing vs. model vs. training)
- Modularization: two distinct model modules share the same training and evaluation engine
- Single responsibility: each script (deep_nn.py, single_layer_nn.py) orchestrates data + model + training

##### Detail
- Hyperparameters (learning rate, epochs, layer sizes) near the training loop.
- Data splits if implemented (train vs. test).
- That both deep_nn.py and single_layer_nn.py share the loader/preprocessor and evaluator modules.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Layer
    DS["face_all.pickle"]:::data
    DL["Data Loader\n(pickle → NumPy arrays)"]:::data
    PR["Preprocessor\n(reshape/normalize)"]:::data

    DS --> DL
    DL --> PR

    %% Model Definitions
    SL["SingleLayerNN"]:::model
    DP["DeepNN"]:::model

    PR --> SL
    PR --> DP

    %% Training & Evaluation Loop
    subgraph "Training & Evaluation"
        TL["Training Loop\n(forward/backprop/update)\n[epochs, lr]"]:::train
        EV["Evaluator\n(loss & accuracy)"]:::train

        SL --> TL
        DP --> TL
        TL --> SL
        TL --> DP
        TL --> EV
    end

    %% Outputs
    MP["Metrics & Logs\n(Console output)"]:::train
    TP["Trained Parameters"]:::train

    EV --> MP
    EV --> TP

    %% External Libraries
    NP["NumPy"]:::external
    PK["pickle"]:::external

    PK -.-> DL
    NP -.-> DL
    NP -.-> PR

    %% Documentation
    RD["README.md"]:::external

    %% Click Events
    click DS "https://github.com/falcon97/celeba-face-classification/blob/master/face_all.pickle"
    click DL "https://github.com/falcon97/celeba-face-classification/blob/master/deep_nn.py"
    click DL "https://github.com/falcon97/celeba-face-classification/blob/master/single_layer_nn.py"
    click SL "https://github.com/falcon97/celeba-face-classification/blob/master/single_layer_nn.py"
    click DP "https://github.com/falcon97/celeba-face-classification/blob/master/deep_nn.py"
    click TL "https://github.com/falcon97/celeba-face-classification/blob/master/deep_nn.py"
    click TL "https://github.com/falcon97/celeba-face-classification/blob/master/single_layer_nn.py"
    click RD "https://github.com/falcon97/celeba-face-classification/blob/master/README.md"

    %% Styles
    classDef data fill:#ADD8E6,stroke:#000,color:#000;
    classDef model fill:#90EE90,stroke:#000,color:#000;
    classDef train fill:#FFA500,stroke:#000,color:#000;
    classDef external fill:#D3D3D3,stroke:#000,color:#000;
```
