# jgaldeano96/tfm-pedestrian-traffic-light architecture

> Architecture diagram of the GitHub repository jgaldeano96/tfm-pedestrian-traffic-light, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jgaldeano96/tfm-pedestrian-traffic-light
- Repository: https://github.com/jgaldeano96/tfm-pedestrian-traffic-light

## Overview

This repository supports a traffic-light video analysis demo and the research workflow behind its models: preparing annotated data, training YOLO and classifier models, and evaluating them under day/night conditions. In the demo, a user selects video and inference options; the app loads configured models, processes the video frame by frame, and presents a downloadable annotated result with timing and summary metrics. Dataset and training relationships beyond the shown calls are represented conservatively: some scripts are listed in the source index but their implementation was not excerpted.

Main entry points: [`app.py`](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/blob/main/app.py) (Streamlit app), [`data/datasets`](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/tree/main/data/datasets) (Train and test datasets), [`tfm_demo/video_processing.py`](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/blob/main/tfm_demo/video_processing.py) (Video processing), [`scripts/dataset`](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/tree/main/scripts/dataset) (Dataset workflows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_demo["Video demo"]
  node_app["Streamlit app<br/>[app.py]"]
  node_result["Annotated MP4"]
end

subgraph group_inference["Inference runtime"]
  node_config["Model configuration<br/>[config.py]"]
  node_model_load["Model loading<br/>[model_loading.py]"]
  node_video["Video processing"]
  node_infer["Detection and classification<br/>[inference.py]"]
end

subgraph group_data["Dataset preparation"]
  node_annotations["Label Studio exports"]
  node_preprocess["Video preprocessing"]
  node_dataset_tools["Dataset generation"]
  node_dataset_scripts["Dataset workflows"]
  node_prepared_data["Train and test datasets"]
end

subgraph group_research["Training and evaluation"]
  node_yolo_training["YOLO training<br/>[yolo26_training.py]"]
  node_cnn_training["Classifier training<br/>[CNN_training.py]"]
  node_models["Trained model files"]
  node_evaluation["Test evaluation"]
  node_metrics["Evaluation results"]
end

node_user(("Demo user"))
node_video_input["Input video"]

node_user -->|"uses"| node_app
node_user -->|"selects"| node_video_input
node_app -->|"gets model settings"| node_config
node_app -->|"loads models"| node_model_load
node_app -->|"processes video"| node_video
node_video_input -.->|"provides frames"| node_video
node_video -->|"runs inference"| node_infer
node_model_load -->|"provides model sessions"| node_infer
node_video -->|"encodes output"| node_result
node_app -->|"offers download"| node_result
node_annotations -.->|"supplies labels"| node_dataset_tools
node_dataset_scripts -->|"calls helpers"| node_dataset_tools
node_dataset_scripts -.->|"writes datasets"| node_prepared_data
node_preprocess -.->|"prepares frames"| node_prepared_data
node_prepared_data -.->|"training input"| node_yolo_training
node_prepared_data -.->|"training input"| node_cnn_training
node_yolo_training -.->|"saves weights"| node_models
node_cnn_training -.->|"exports classifier"| node_models
node_prepared_data -.->|"test input"| node_evaluation
node_evaluation -.->|"writes metrics"| node_metrics

click node_app "https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/blob/main/app.py"
click node_config "https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/blob/main/tfm_demo/config.py"
click node_model_load "https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/blob/main/tfm_demo/model_loading.py"
click node_video "https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/blob/main/tfm_demo/video_processing.py"
click node_infer "https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/blob/main/tfm_demo/inference.py"
click node_annotations "https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/tree/main/data/annotation_exports"
click node_preprocess "https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/tree/main/scripts/preprocessing"
click node_dataset_tools "https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/blob/main/scripts/utils/dataset_functions.py"
click node_dataset_scripts "https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/tree/main/scripts/dataset"
click node_prepared_data "https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/tree/main/data/datasets"
click node_yolo_training "https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/blob/main/scripts/training/yolo26_training.py"
click node_cnn_training "https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/blob/main/scripts/training/CNN_training.py"
click node_models "https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/tree/main/models"
click node_evaluation "https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/tree/main/scripts/test"
click node_metrics "https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/tree/main/results"

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_result,node_user toneBlue
class node_config,node_model_load,node_video,node_infer toneAmber
class node_annotations,node_preprocess,node_dataset_tools,node_dataset_scripts,node_prepared_data toneMint
class node_yolo_training,node_cnn_training,node_models,node_evaluation,node_metrics toneRose
class node_video_input toneIndigo
```

## Components

### Video demo

- [Streamlit app](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/blob/main/app.py): `app.py`
- **Annotated MP4**

### Inference runtime

- [Model configuration](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/blob/main/tfm_demo/config.py): `tfm_demo/config.py`
- [Model loading](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/blob/main/tfm_demo/model_loading.py): `tfm_demo/model_loading.py`
- [Video processing](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/blob/main/tfm_demo/video_processing.py): `tfm_demo/video_processing.py`
- [Detection and classification](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/blob/main/tfm_demo/inference.py): `tfm_demo/inference.py`

### Dataset preparation

- [Label Studio exports](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/tree/main/data/annotation_exports): `data/annotation_exports`
- [Video preprocessing](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/tree/main/scripts/preprocessing): `scripts/preprocessing`
- [Dataset generation](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/blob/main/scripts/utils/dataset_functions.py): `scripts/utils/dataset_functions.py`
- [Dataset workflows](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/tree/main/scripts/dataset): `scripts/dataset`
- [Train and test datasets](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/tree/main/data/datasets): `data/datasets`

### Training and evaluation

- [YOLO training](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/blob/main/scripts/training/yolo26_training.py): `scripts/training/yolo26_training.py`
- [Classifier training](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/blob/main/scripts/training/CNN_training.py): `scripts/training/CNN_training.py`
- [Trained model files](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/tree/main/models): `models`
- [Test evaluation](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/tree/main/scripts/test): `scripts/test`
- [Evaluation results](https://github.com/jgaldeano96/tfm-pedestrian-traffic-light/tree/main/results): `results`

### Other components

- **Demo user**
- **Input video**

## Connections

- Demo user → Streamlit app: uses (evidence: `app.py`)
- Demo user → Input video: selects
- Streamlit app → Model configuration: gets model settings (evidence: `app.py`)
- Streamlit app → Model loading: loads models (evidence: `app.py`)
- Streamlit app → Video processing: processes video (evidence: `app.py`)
- Input video → Video processing: provides frames (evidence: `tfm_demo/video_processing.py`)
- Video processing → Detection and classification: runs inference (evidence: `tfm_demo/video_processing.py`)
- Model loading → Detection and classification: provides model sessions (evidence: `tfm_demo/inference.py`)
- Video processing → Annotated MP4: encodes output (evidence: `tfm_demo/video_processing.py`)
- Streamlit app → Annotated MP4: offers download (evidence: `app.py`)
- Label Studio exports → Dataset generation: supplies labels
- Dataset workflows → Dataset generation: calls helpers (evidence: `scripts/dataset/create_classifier_dataset.py`)
- Dataset workflows → Train and test datasets: writes datasets
- Video preprocessing → Train and test datasets: prepares frames
- Train and test datasets → YOLO training: training input
- Train and test datasets → Classifier training: training input
- YOLO training → Trained model files: saves weights
- Classifier training → Trained model files: exports classifier
- Train and test datasets → Test evaluation: test input
- Test evaluation → Evaluation results: writes metrics
