Downloads · 30 days
0
shivam-kumar098/anomaly-detector-v1.1
anomaly-detector-v1.1 is a machine learning model from shivam-kumar098. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
A Gradio GUI for LGN-Net (Local-Global Normality Network, Zhao et al.) — a video future-frame-prediction anomaly detector. It predicts frame N from frames N-4 .. N-1; frames it fails to predict well (vs. its learned m…
Downloads · 30 days
0
Access
Public
Updated Sep 6, 2026
Repo size
91.5 MB
Likes
0
Public
Click a slice to open those files.
.pth91.1 MB · 100%
From the Hugging Face model README
A Gradio GUI for LGN-Net (Local-Global Normality Network, Zhao et al.) — a video future-frame-prediction anomaly detector. It predicts frame N from frames N-4 .. N-1; frames it fails to predict well (vs. its learned memory of "normal" patterns) are flagged as anomalies.
The original training script saves two separate files per epoch:
torch.save(model.state_dict(), 'Nmodel.pth') # network weights
torch.save(m_items, 'Nkeys.pt') # the memory bank ("normal" prototypes)
You need both. model.pth alone will load without error, but the
memory bank will be an untrained random tensor and every anomaly score
will be meaningless. Locate the matching Nkeys.pt from your training
run and rename it keys.pt next to model.pth in this folder.
app.py — Gradio GUI (Video tab + 5-frame Image Sequence tab)model.py — faithful port of the LGN-Net architecture (Encoder/Decoder/
Predictor/ConvLSTM/Memory) plus CPU-safe inference helpersmodel.pth — you must add this (network weights / state_dict)keys.pt — you must add this (memory bank, see above)requirements.txtThe network's Encoder/Decoder are hardcoded to n_channel=3. The
original UCSD Ped2 dataset is grayscale but loaded via cv2.imread,
which replicates it into 3 identical channels. model.py does the same
replication automatically for grayscale input — there is no literal
single-channel mode.
A single still image has no temporal context, so it cannot produce a
meaningful anomaly score on its own. The Video tab is the intended
use case: it slides a 5-frame window across the whole clip and computes
a calibrated 0–1 anomaly score per frame (normalized using that video's
own PSNR / feature-distance statistics, exactly as in the paper's
Evaluate.py). The Image Sequence tab accepts exactly 5 consecutive
frames for quick testing, but can only report raw, uncalibrated metrics
(PSNR, feature distance) since normalization needs a full video.
model.pth and keys.pt.app.py.pip install -r requirements.txt
python app.py