# yaswanthkumarmallela01/abnormal-event-detection architecture

> Architecture diagram of the GitHub repository yaswanthkumarmallela01/abnormal-event-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yaswanthkumarmallela01/abnormal-event-detection
- Repository: https://github.com/yaswanthkumarmallela01/abnormal-event-detection

## Overview

This is a Flask-based surveillance-video anomaly detection application. Users upload a video or analyze a browser camera feed; the Flask app dispatches inference locally or to the optional Modal service, then returns scores, alerts, and visual results. IP-camera middleware can submit frames through a documented API. The core analysis extracts and preprocesses frames, scores sequences with a ConvLSTM autoencoder, and applies thresholding. Optional training produces model weights and a threshold. Relationships not evidenced by excerpts or README statements are omitted; Modal integration is shown as optional.

Main entry points: [`app.py`](https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/app.py) (Flask application), [`pipeline.py`](https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/pipeline.py) (Video analysis), [`static/app.js`](https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/static/app.js) (Client controls), [`model/convlstm_autoencoder.py`](https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/model/convlstm_autoencoder.py) (ConvLSTM autoencoder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webui["Web interface<br/>[index.html]"]
  node_browserlogic["Client controls<br/>[app.js]"]
  node_results["Alerts and visualization<br/>[app.js]"]
end

subgraph group_api["Application and inference"]
  node_flask["Flask application<br/>[app.py]"]
  node_modal["Modal inference service<br/>[modal_infer.py]"]
end

subgraph group_analysis["Anomaly analysis"]
  node_pipeline["Video analysis<br/>[pipeline.py]"]
  node_preprocessing["Frame preprocessing<br/>[pipeline.py]"]
  node_scoring["Sequence scoring<br/>[pipeline.py]"]
  node_thresholding["Adaptive thresholding<br/>[pipeline.py]"]
  node_enrichment["Detection utilities<br/>[detection_utils.py]"]
end

subgraph group_models["Models and training"]
  node_model["ConvLSTM autoencoder"]
  node_training["Model training<br/>[train.py]"]
  node_weights[("Model weights")]
end

node_viewer(("Viewer"))
node_camera(("Browser camera"))
node_middleware(("IP camera middleware"))

node_viewer -->|"uses"| node_webui
node_webui -->|"loads"| node_browserlogic
node_browserlogic -->|"submits video"| node_flask
node_camera -->|"provides frames"| node_browserlogic
node_browserlogic -->|"posts frames"| node_flask
node_middleware -->|"posts frames"| node_flask
node_flask -->|"runs locally"| node_pipeline
node_flask -->|"requests event hints"| node_enrichment
node_flask -.->|"dispatches optionally"| node_modal
node_modal -->|"builds model"| node_model
node_pipeline -->|"prepares frames"| node_preprocessing
node_preprocessing -->|"forms sequences"| node_scoring
node_pipeline -->|"builds model"| node_model
node_scoring -->|"scores sequences"| node_thresholding
node_pipeline -->|"calculates threshold"| node_thresholding
node_flask -->|"returns results"| node_results
node_browserlogic -->|"renders alerts"| node_results
node_training -->|"trains"| node_model
node_training -->|"saves weights"| node_weights
node_pipeline -->|"loads threshold"| node_weights

click node_webui "https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/templates/index.html"
click node_browserlogic "https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/static/app.js"
click node_flask "https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/app.py"
click node_modal "https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/modal_infer.py"
click node_pipeline "https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/pipeline.py"
click node_preprocessing "https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/pipeline.py"
click node_scoring "https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/pipeline.py"
click node_thresholding "https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/pipeline.py"
click node_enrichment "https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/detection_utils.py"
click node_results "https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/static/app.js"
click node_model "https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/model/convlstm_autoencoder.py"
click node_training "https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/train.py"
click node_weights "https://github.com/yaswanthkumarmallela01/abnormal-event-detection/tree/master/weights"

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_webui,node_browserlogic,node_results,node_viewer,node_camera toneBlue
class node_flask,node_modal toneAmber
class node_pipeline,node_preprocessing,node_scoring,node_thresholding,node_enrichment toneMint
class node_model,node_training,node_weights toneRose
class node_middleware toneIndigo
```

## Components

### Web experience

- [Web interface](https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/templates/index.html): `templates/index.html`
- [Client controls](https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/static/app.js): `static/app.js`
- [Alerts and visualization](https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/static/app.js): `static/app.js`

### Application and inference

- [Flask application](https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/app.py): `app.py`
- [Modal inference service](https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/modal_infer.py): `modal_infer.py`

### Anomaly analysis

- [Video analysis](https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/pipeline.py): `pipeline.py`
- [Frame preprocessing](https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/pipeline.py): `pipeline.py`
- [Sequence scoring](https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/pipeline.py): `pipeline.py`
- [Adaptive thresholding](https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/pipeline.py): `pipeline.py`
- [Detection utilities](https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/detection_utils.py): `detection_utils.py`

### Models and training

- [ConvLSTM autoencoder](https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/model/convlstm_autoencoder.py): `model/convlstm_autoencoder.py`
- [Model training](https://github.com/yaswanthkumarmallela01/abnormal-event-detection/blob/master/train.py): `train.py`
- [Model weights](https://github.com/yaswanthkumarmallela01/abnormal-event-detection/tree/master/weights): `weights`

### Other components

- **Viewer**
- **Browser camera**
- **IP camera middleware**

## Connections

- Viewer → Web interface: uses (evidence: `README.md`)
- Web interface → Client controls: loads (evidence: `README.md`)
- Client controls → Flask application: submits video (evidence: `README.md`)
- Browser camera → Client controls: provides frames (evidence: `static/app.js`)
- Client controls → Flask application: posts frames (evidence: `static/app.js`)
- IP camera middleware → Flask application: posts frames (evidence: `README.md`)
- Flask application → Video analysis: runs locally (evidence: `app.py`)
- Flask application → Detection utilities: requests event hints (evidence: `app.py`)
- Flask application → Modal inference service: dispatches optionally (evidence: `app.py`)
- Modal inference service → ConvLSTM autoencoder: builds model (evidence: `modal_infer.py`)
- Video analysis → Frame preprocessing: prepares frames (evidence: `pipeline.py`)
- Frame preprocessing → Sequence scoring: forms sequences (evidence: `pipeline.py`)
- Video analysis → ConvLSTM autoencoder: builds model (evidence: `pipeline.py`)
- Sequence scoring → Adaptive thresholding: scores sequences (evidence: `pipeline.py`)
- Video analysis → Adaptive thresholding: calculates threshold (evidence: `pipeline.py`)
- Flask application → Alerts and visualization: returns results (evidence: `static/app.js`)
- Client controls → Alerts and visualization: renders alerts (evidence: `static/app.js`)
- Model training → ConvLSTM autoencoder: trains (evidence: `train.py`)
- Model training → Model weights: saves weights (evidence: `README.md`)
- Video analysis → Model weights: loads threshold (evidence: `pipeline.py`)
