# krmantavya/anomaly-detection-in-videos architecture

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

- Interactive diagram: https://gitdiagram.com/krmantavya/anomaly-detection-in-videos
- Repository: https://github.com/krmantavya/anomaly-detection-in-videos

## Overview

This is a research pipeline for detecting anomalous frames in UCSD pedestrian videos: prepare frames, derive CNN features, fit or apply a one-class SVM, then assess predictions. The sampled scripts show feature extraction and SVM evaluation together in the hyperparameter tool, plus separate preprocessing and evaluation utilities. The README mentions temporal data, but the available excerpts do not show a distinct temporal-modeling stage; the initialization scripts also depend on extractor and classifier modules absent from the tree, so those links are not inferred.

Main entry points: [`Scripts/hyperparameter.py`](https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/hyperparameter.py) (One-class SVM), [`Scripts/MeanImage.npy`](https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/MeanImage.npy) (Mean image), [`Scripts/evaluate.py`](https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/evaluate.py) (Prediction evaluation), [`Scripts/computeMeanImage.py`](https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/computeMeanImage.py) (Mean image generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Frame Preparation"]
  node_rgb["RGB conversion<br/>[convertToRGB.py]"]
  node_mean["Mean image generation"]
  node_meanfile["Mean image<br/>[MeanImage.npy]"]
end

subgraph group_model["Feature Modeling"]
  node_cnn["CNN feature extraction<br/>[hyperparameter.py]"]
  node_caffenet["CaffeNet definition<br/>[deploy.prototxt]"]
  node_svm["One-class SVM<br/>[hyperparameter.py]"]
  node_models[("Saved classifiers")]
end

subgraph group_assessment["Evaluation"]
  node_labels["UCSD frame labels<br/>[UCSDped1.m]"]
  node_evaluate["Prediction evaluation<br/>[evaluate.py]"]
  node_tune["Parameter tuning<br/>[hyperparameter.py]"]
  node_plot["Feature visualization<br/>[drawFigure.py]"]
end

node_video(("Video frames"))

node_video -->|"converts TIFFs"| node_rgb
node_mean -->|"saves mean"| node_meanfile
node_meanfile -->|"normalizes input"| node_cnn
node_cnn -->|"provides features"| node_svm
node_svm -->|"tests predictions"| node_tune
node_labels -.->|"labels frames"| node_evaluate
node_svm -.->|"produces predictions"| node_evaluate
node_cnn -.->|"uses definition"| node_caffenet
node_svm -.->|"saves or loads"| node_models
node_svm -.->|"supplies predictions"| node_plot

click node_rgb "https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/convertToRGB.py"
click node_mean "https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/computeMeanImage.py"
click node_meanfile "https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/MeanImage.npy"
click node_cnn "https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/hyperparameter.py"
click node_caffenet "https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Models/bvlc_reference_caffenet/deploy.prototxt"
click node_svm "https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/hyperparameter.py"
click node_models "https://github.com/krmantavya/anomaly-detection-in-videos/tree/master/Classifier"
click node_labels "https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/TargetLabels/UCSDped1.m"
click node_evaluate "https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/evaluate.py"
click node_tune "https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/hyperparameter.py"
click node_plot "https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/drawFigure.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_rgb,node_mean,node_meanfile toneBlue
class node_cnn,node_caffenet,node_svm,node_models toneAmber
class node_labels,node_evaluate,node_tune,node_plot toneMint
class node_video toneIndigo
```

## Components

### Frame Preparation

- [RGB conversion](https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/convertToRGB.py): `Scripts/convertToRGB.py`
- [Mean image generation](https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/computeMeanImage.py): `Scripts/computeMeanImage.py`
- [Mean image](https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/MeanImage.npy): `Scripts/MeanImage.npy`

### Feature Modeling

- [CNN feature extraction](https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/hyperparameter.py): `Scripts/hyperparameter.py`
- [CaffeNet definition](https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Models/bvlc_reference_caffenet/deploy.prototxt): `Models/bvlc_reference_caffenet/deploy.prototxt`
- [One-class SVM](https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/hyperparameter.py): `Scripts/hyperparameter.py`
- [Saved classifiers](https://github.com/krmantavya/anomaly-detection-in-videos/tree/master/Classifier): `Classifier`

### Evaluation

- [UCSD frame labels](https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/TargetLabels/UCSDped1.m): `TargetLabels/UCSDped1.m`
- [Prediction evaluation](https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/evaluate.py): `Scripts/evaluate.py`
- [Parameter tuning](https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/hyperparameter.py): `Scripts/hyperparameter.py`
- [Feature visualization](https://github.com/krmantavya/anomaly-detection-in-videos/blob/master/Scripts/drawFigure.py): `Scripts/drawFigure.py`

### Other components

- **Video frames**

## Connections

- Video frames → RGB conversion: converts TIFFs (evidence: `Scripts/convertToRGB.py`)
- Mean image generation → Mean image: saves mean (evidence: `Scripts/computeMeanImage.py`)
- Mean image → CNN feature extraction: normalizes input (evidence: `Scripts/hyperparameter.py`)
- CNN feature extraction → One-class SVM: provides features (evidence: `Scripts/hyperparameter.py`)
- One-class SVM → Parameter tuning: tests predictions (evidence: `Scripts/hyperparameter.py`)
- UCSD frame labels → Prediction evaluation: labels frames
- One-class SVM → Prediction evaluation: produces predictions
- CNN feature extraction → CaffeNet definition: uses definition
- One-class SVM → Saved classifiers: saves or loads
- One-class SVM → Feature visualization: supplies predictions
