# jahnavi-deshkar/real_time_mask_detection_system architecture

> Architecture diagram of the GitHub repository jahnavi-deshkar/real_time_mask_detection_system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jahnavi-deshkar/real_time_mask_detection_system
- Repository: https://github.com/jahnavi-deshkar/real_time_mask_detection_system
- Video tour (about a minute): https://gitdiagram.com/jahnavi-deshkar/real_time_mask_detection_system/video

## Overview

This is a local Streamlit mask-compliance video prototype: a user uploads a video, the app reads frames and passes them to an ONNX-backed detector, then displays annotated frames and a cumulative violation count. The README also describes webcam input and cooldown-based CSV logging; the sampled app does not implement webcam handling or call the tracker, so those capabilities are shown only where their documented or implemented behavior is supported. The detector and tracker source were sampled; other README-described UI details are not independently verified.

Main entry points: [`app.py`](https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/app.py) (Streamlit app), [`src/detector.py`](https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/src/detector.py) (Frame detector), [`src/tracker.py`](https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/src/tracker.py) (Violation tracker), [`models/best.onnx`](https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/models/best.onnx) (Trained model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Video interface"]
  node_app["Streamlit app<br/>[app.py]"]
  node_video["Uploaded video"]
  node_frames["Frame acquisition<br/>[app.py]"]
  node_display["Annotated display<br/>[app.py]"]
end

subgraph group_detection["Detection"]
  node_detector["Frame detector<br/>[detector.py]"]
  node_preprocess["Preprocessing<br/>[detector.py]"]
  node_onnx["ONNX inference<br/>[detector.py]"]
  node_model["Trained model<br/>[best.onnx]"]
  node_filter["Confidence filter<br/>[detector.py]"]
  node_classify["Classify violations<br/>[detector.py]"]
  node_annotate["Draw detections<br/>[detector.py]"]
end

subgraph group_logging["Violation logging"]
  node_tracker["Violation tracker<br/>[tracker.py]"]
  node_csv[("Violation log<br/>[logs.csv]")]
end

node_user(("Video user"))

node_user -->|"uploads video"| node_app
node_app -->|"stores temporary copy"| node_video
node_app -->|"opens and reads"| node_frames
node_frames -->|"passes frames"| node_detector
node_app -->|"sets threshold"| node_detector
node_detector -->|"prepares frame"| node_preprocess
node_preprocess -->|"supplies tensor"| node_onnx
node_onnx -->|"runs inference"| node_model
node_onnx -->|"returns detections"| node_filter
node_filter -->|"accepts detections"| node_classify
node_classify -->|"labels and counts"| node_annotate
node_detector -->|"returns frame and count"| node_display
node_display -->|"renders results"| node_app
node_tracker -->|"appends cooled-down violations"| node_csv

click node_app "https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/app.py"
click node_frames "https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/app.py"
click node_display "https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/app.py"
click node_detector "https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/src/detector.py"
click node_preprocess "https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/src/detector.py"
click node_onnx "https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/src/detector.py"
click node_model "https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/models/best.onnx"
click node_filter "https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/src/detector.py"
click node_classify "https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/src/detector.py"
click node_annotate "https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/src/detector.py"
click node_tracker "https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/src/tracker.py"
click node_csv "https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/data/logs.csv"

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_video,node_frames,node_display,node_user toneBlue
class node_detector,node_preprocess,node_onnx,node_model,node_filter,node_classify,node_annotate toneAmber
class node_tracker,node_csv toneMint
```

## Components

### Video interface

- [Streamlit app](https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/app.py): `app.py`
- **Uploaded video**
- [Frame acquisition](https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/app.py): `app.py`
- [Annotated display](https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/app.py): `app.py`

### Detection

- [Frame detector](https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/src/detector.py): `src/detector.py`
- [Preprocessing](https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/src/detector.py): `src/detector.py`
- [ONNX inference](https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/src/detector.py): `src/detector.py`
- [Trained model](https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/models/best.onnx): `models/best.onnx`
- [Confidence filter](https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/src/detector.py): `src/detector.py`
- [Classify violations](https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/src/detector.py): `src/detector.py`
- [Draw detections](https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/src/detector.py): `src/detector.py`

### Violation logging

- [Violation tracker](https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/src/tracker.py): `src/tracker.py`
- [Violation log](https://github.com/jahnavi-deshkar/real_time_mask_detection_system/blob/main/data/logs.csv): `data/logs.csv`

### Other components

- **Video user**

## Connections

- Video user → Streamlit app: uploads video
- Streamlit app → Uploaded video: stores temporary copy
- Streamlit app → Frame acquisition: opens and reads
- Frame acquisition → Frame detector: passes frames
- Streamlit app → Frame detector: sets threshold
- Frame detector → Preprocessing: prepares frame
- Preprocessing → ONNX inference: supplies tensor
- ONNX inference → Trained model: runs inference
- ONNX inference → Confidence filter: returns detections
- Confidence filter → Classify violations: accepts detections
- Classify violations → Draw detections: labels and counts
- Frame detector → Annotated display: returns frame and count
- Annotated display → Streamlit app: renders results
- Violation tracker → Violation log: appends cooled-down violations
