# hamdha-saheer/look-eyewear-recommendation architecture

> Architecture diagram of the GitHub repository hamdha-saheer/look-eyewear-recommendation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hamdha-saheer/look-eyewear-recommendation
- Repository: https://github.com/hamdha-saheer/look-eyewear-recommendation

## Overview

LOOK is a face-shape and glasses recommendation web app with an image-based prediction flow and virtual try-on. Its Flask routes coordinate face detection, shape inference, recommendation lookup, and overlay generation; users can also request recommendations for a manually selected shape. The repository additionally includes dataset preparation and two model-training scripts. Dataset files and trained weights are not present in the tree, so those data relationships are shown only where supported by the excerpts.

Main entry points: [`app.py`](https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/app.py) (Flask routes), [`try_on.py`](https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/try_on.py) (Glasses overlay), [`model`](https://github.com/hamdha-saheer/look-eyewear-recommendation/tree/master/model) (Trained weights), [`clean_data.py`](https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/clean_data.py) (Dataset cleaning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Flask routes<br/>[app.py]"]
  node_ui["Web interface<br/>[index.html]"]
  node_result["Prediction and overlay response<br/>[app.py]"]
end

subgraph group_vision["Face vision"]
  node_face["Face processing<br/>[face_utils.py]"]
  node_predict["Shape inference<br/>[app.py]"]
  node_model[("Trained weights")]
  node_classes["Class mappings<br/>[classes_male.json]"]
end

subgraph group_catalog["Recommendations and try-on"]
  node_recs["Recommendation data"]
  node_glasses[("Glasses images")]
  node_overlay["Glasses overlay<br/>[try_on.py]"]
end

subgraph group_ml["Model development"]
  node_clean["Dataset cleaning<br/>[clean_data.py]"]
  node_balance["Class balancing<br/>[balance_data.py]"]
  node_train["Model training<br/>[train_model.py]"]
  node_trainml["Tracked training"]
  node_datasets[("Image datasets")]
end

node_user(("User"))

node_user -->|"uses"| node_ui
node_ui -->|"submits requests"| node_app
node_app -->|"crops and landmarks"| node_face
node_app -->|"runs inference"| node_predict
node_predict -->|"loads weights"| node_model
node_predict -->|"maps classes"| node_classes
node_app -->|"looks up recommendations"| node_recs
node_app -->|"indexes images"| node_glasses
node_app -->|"requests overlay"| node_overlay
node_overlay -->|"reads PNG"| node_glasses
node_overlay -->|"writes image"| node_result
node_app -->|"returns JSON or image"| node_result
node_clean -->|"crops images"| node_face
node_clean -->|"writes cleaned splits"| node_datasets
node_balance -->|"balances training images"| node_datasets
node_train -->|"loads cleaned splits"| node_datasets
node_trainml -->|"loads cleaned splits"| node_datasets
node_train -->|"saves checkpoints"| node_model
node_trainml -->|"saves checkpoints and classes"| node_model

click node_app "https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/app.py"
click node_ui "https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/templates/index.html"
click node_face "https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/face_utils.py"
click node_predict "https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/app.py"
click node_model "https://github.com/hamdha-saheer/look-eyewear-recommendation/tree/master/model"
click node_classes "https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/model/classes_male.json"
click node_recs "https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/recommendations.json"
click node_glasses "https://github.com/hamdha-saheer/look-eyewear-recommendation/tree/master/static/glasses"
click node_overlay "https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/try_on.py"
click node_clean "https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/clean_data.py"
click node_balance "https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/balance_data.py"
click node_train "https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/train_model.py"
click node_trainml "https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/train_model_mlflow.py"
click node_result "https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/app.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_ui,node_result,node_user toneBlue
class node_face,node_predict,node_model,node_classes toneAmber
class node_recs,node_glasses,node_overlay toneMint
class node_clean,node_balance,node_train,node_trainml,node_datasets toneRose
```

## Components

### Web application

- [Flask routes](https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/app.py): `app.py`
- [Web interface](https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/templates/index.html): `templates/index.html`
- [Prediction and overlay response](https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/app.py): `app.py`

### Face vision

- [Face processing](https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/face_utils.py): `face_utils.py`
- [Shape inference](https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/app.py): `app.py`
- [Trained weights](https://github.com/hamdha-saheer/look-eyewear-recommendation/tree/master/model): `model`
- [Class mappings](https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/model/classes_male.json): `model/classes_male.json`

### Recommendations and try-on

- [Recommendation data](https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/recommendations.json): `recommendations.json`
- [Glasses images](https://github.com/hamdha-saheer/look-eyewear-recommendation/tree/master/static/glasses): `static/glasses`
- [Glasses overlay](https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/try_on.py): `try_on.py`

### Model development

- [Dataset cleaning](https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/clean_data.py): `clean_data.py`
- [Class balancing](https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/balance_data.py): `balance_data.py`
- [Model training](https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/train_model.py): `train_model.py`
- [Tracked training](https://github.com/hamdha-saheer/look-eyewear-recommendation/blob/master/train_model_mlflow.py): `train_model_mlflow.py`
- **Image datasets**

### Other components

- **User**

## Connections

- User → Web interface: uses
- Web interface → Flask routes: submits requests (evidence: `app.py`)
- Flask routes → Face processing: crops and landmarks (evidence: `app.py`)
- Flask routes → Shape inference: runs inference (evidence: `app.py`)
- Shape inference → Trained weights: loads weights (evidence: `app.py`)
- Shape inference → Class mappings: maps classes (evidence: `app.py`)
- Flask routes → Recommendation data: looks up recommendations (evidence: `app.py`)
- Flask routes → Glasses images: indexes images (evidence: `app.py`)
- Flask routes → Glasses overlay: requests overlay (evidence: `app.py`)
- Glasses overlay → Glasses images: reads PNG (evidence: `try_on.py`)
- Glasses overlay → Prediction and overlay response: writes image (evidence: `try_on.py`)
- Flask routes → Prediction and overlay response: returns JSON or image (evidence: `app.py`)
- Dataset cleaning → Face processing: crops images (evidence: `clean_data.py`)
- Dataset cleaning → Image datasets: writes cleaned splits (evidence: `clean_data.py`)
- Class balancing → Image datasets: balances training images (evidence: `balance_data.py`)
- Model training → Image datasets: loads cleaned splits (evidence: `train_model.py`)
- Tracked training → Image datasets: loads cleaned splits (evidence: `train_model_mlflow.py`)
- Model training → Trained weights: saves checkpoints (evidence: `train_model.py`)
- Tracked training → Trained weights: saves checkpoints and classes (evidence: `train_model_mlflow.py`)
