Offcial implementation of "A Hybrid Video Anomaly Detection Framework via Memory-Augmented Flow Reconstruction and Flow-Guided Frame Prediction, ICCV-2021".

Overview

HF2-VAD

Offcial implementation of "A Hybrid Video Anomaly Detection Framework via Memory-Augmented Flow Reconstruction and Flow-Guided Frame Prediction, ICCV-2021".

[Paper] [Supp] [arXiv]

pipeline

1. Dependencies

python==3.6
pytorch==1.5.1
mmcv-full==1.3.1
mmdet==2.11.0
scikit-learn==0.23.2
edflow==0.4.0
PyYAML==5.4.1
tensorboardX==2.4

2. Usage

2.1 Data preparation

Please follow the instructions to prepare the training and testing dataset.

2.2 Train

We train the ML-MemAE-SC at first, then train CVAE model with the reconstructed flows, and finally finetune the whole framework. All the config files are located at ./cfgs.

To train the ML-MemAE-SC, run:

$ python ml_memAE_sc_train.py

To train the CVAE model with reconstructed flows, run:

$ python trian.py

And finetune the whole HF2VAD framework together as:

$ python finetune.py

For different datasets, please modify the configuration files accordingly.

2.3 Evaluation

To evaluation the anomaly detection performance of the trained model, run:

$ python eval.py [--model_save_path] [--cfg_file] 

E.g., for the ped2 dataset:

$ python eval.py \
         --model_save_path=./pretrained_ckpts/ped2_HF2VAD_99.31.pth \
         --cfg_file=./pretrained_ckpts/ped2_HF2VAD_99.31_cfg.yaml

You can download the pretrained weights of HF2VAD for Ped2, Avenue and ShanghaiTech datasets from here.

3. Results

Model UCSD Ped2 CUHK Avenue ShanghaiTech
HF2-VAD 99.3% 91.1% 76.2%

Acknowledgment

We thank jhaux for the PyTorch implementation of the conditional VAE.

Citation

If you find this repo useful, please consider citing:

@inproceedings{liu2021hf2vad,
title = {A Hybrid Video Anomaly Detection Framework via Memory-Augmented Flow Reconstruction and Flow-Guided Frame Prediction},
author = {Liu, Zhian and Nie, Yongwei and Long, Chengjiang and Zhang, Qing and Li, Guiqing},
booktitle={Proceedings of the IEEE International Conference on Computer Vision},
year = {2021}
}
Comments
  • Problem in reproducing results on Avenue

    Problem in reproducing results on Avenue

    Hi,

    Thank you for sharing your contribution to anomaly detection. I tried to reproduce the baseline on the Avenue dataset. However, I got 89.06% AUC after retraining on Avenue. I got only 90.3% even with the pre-trained model. In the paper, it is 91.1%. Could you please share what could be a possible cause for this mismatch?

    Thanks! Neelu

    opened by NeeluMadanCreate 13
  • reproduce problem

    reproduce problem

    Hi, Thank you for providing the code! I follow the instructions to prepare the training and testing dataset, however, only got AUC=81.9% in "avenue".Then I replaced the detection model(cascade_rcnn_r101_fpn_1x_coco_20200317-0b6a2fbf.pth) with "torchvision.models.detection.fasterrcnn_resnet50_fpn", and got AUC=89.7%, may i get your "avenue_bboxes_test.npy" and "avenue_bboxes_train.npy"?

    Many thanks in advance.

    opened by heiheiHelix 3
  • About extracting optical flows

    About extracting optical flows

    When I try to run the command $ python extract_flows.py --proj_root=<path/to/project_root> --dataset_name=ped2 --mode=train It is work but I didn't see anything about the flow in dataset so I just want to know what happen it is?

    opened by ChiSrwi 2
  • Flow Reconstruction

    Flow Reconstruction

    If it's not an excuse, could you tell me the anomaly performance when I only do Flow Reconstruction in avenue? In the paper, 86% came out, but the result I ran only came out 75%. thank you.

    opened by jooyeon-Yee 2
  • what is the code license?

    what is the code license?

    Hi, thanks for presenting your great work, and your dog is very cute. what is the code license? you have not yet added a license for this repository. I would appreciate it if you could add it. Many thanks.

    opened by syrobonkers 1
  • weight of cascade RCNN

    weight of cascade RCNN

    Hello! Thank you for your excellent work. I'm very interested in your work, but I encounter a problem in the preprocessing stage and can't find the preprocessing weight of cascade RCNN . Can you send a download link or upload this weight?

    opened by Sunxiaohu0406 1
  • Where is the chunked_samples <dict>?

    Where is the chunked_samples ?

    Where is the chunked_samples ? In datasets/dataset.py, the function "Chunked_sample_dataset" obtain a data dict,the keys are "appearance\motion\bbox\pred_frame\sample_id" ,but where are the keys and values?

    opened by DaffTangEclipse 1
  • cascade RCNN pretrained weights download error

    cascade RCNN pretrained weights download error

    Hello, I got a problem of donwloading mmdetection pretrain model.

    Downloading: "https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/v2.0/cascade_rcnn/cascade_rcnn_r101_fpn_1x_coco/cascade_rcnn_r101_fpn_1x_coco_20200317-0b6a2fbf.pth" to /home/tianye/.cache/torch/hub/checkpoints/cascade_rcnn_r101_fpn_1x_coco_20200317-0b6a2fbf.pth Traceback (most recent call last): File "", line 1, in File "/home/tianye/mmdetection/mmdet/apis/inference.py", line 43, in init_detector checkpoint = load_checkpoint(model, checkpoint, map_location=map_loc) File "/home/tianye/anaconda3/envs/hf2vad/lib/python3.6/site-packages/mmcv/runner/checkpoint.py", line 513, in load_checkpoint checkpoint = _load_checkpoint(filename, map_location, logger) File "/home/tianye/anaconda3/envs/hf2vad/lib/python3.6/site-packages/mmcv/runner/checkpoint.py", line 451, in _load_checkpoint return CheckpointLoader.load_checkpoint(filename, map_location, logger) File "/home/tianye/anaconda3/envs/hf2vad/lib/python3.6/site-packages/mmcv/runner/checkpoint.py", line 244, in load_checkpoint return checkpoint_loader(filename, map_location) File "/home/tianye/anaconda3/envs/hf2vad/lib/python3.6/site-packages/mmcv/runner/checkpoint.py", line 284, in load_from_http filename, model_dir=model_dir, map_location=map_location) File "/home/tianye/anaconda3/envs/hf2vad/lib/python3.6/site-packages/torch/hub.py", line 553, in load_state_dict_from_url download_url_to_file(url, cached_file, hash_prefix, progress=progress) File "/home/tianye/anaconda3/envs/hf2vad/lib/python3.6/site-packages/torch/hub.py", line 419, in download_url_to_file u = urlopen(req) File "/home/tianye/anaconda3/envs/hf2vad/lib/python3.6/urllib/request.py", line 223, in urlopen return opener.open(url, data, timeout) File "/home/tianye/anaconda3/envs/hf2vad/lib/python3.6/urllib/request.py", line 532, in open response = meth(req, response) File "/home/tianye/anaconda3/envs/hf2vad/lib/python3.6/urllib/request.py", line 642, in http_response 'http', request, response, code, msg, hdrs) File "/home/tianye/anaconda3/envs/hf2vad/lib/python3.6/urllib/request.py", line 570, in error return self._call_chain(*args) File "/home/tianye/anaconda3/envs/hf2vad/lib/python3.6/urllib/request.py", line 504, in _call_chain result = func(*args) File "/home/tianye/anaconda3/envs/hf2vad/lib/python3.6/urllib/request.py", line 650, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: Forbidden

    Would you like to upload the cascade RCNN pretrained weights which your paper used? It could definetely be useful to any other ones who want to train their own ML-MemAE-SC model. Thanks so much~

    opened by MAXxYe 1
  • Minor question

    Minor question

    For this line: https://github.com/LiUzHiAn/hf2vad/blob/abfde047f75586faf04ffe767ae53062b848bd63/utils/eval_utils.py#L74

    is my following interpretation correct? I am trying to use this implementation in my work.

    truth is ground truth labels with normal frames as 0 and anomaly frames as 1, preds has (hopefully) lower value for normal frame and higher value for anomaly frames. pos label=1 because the anomaly is 1 in ground truth labels.

    opened by abhishekaich27 1
  • correlation_package安装错误

    correlation_package安装错误

    channelnorm_package和resample2d_package都没有问题 correlation_package安装报错 correlation_cuda.cc(7): fatal error C1083: 无法打开包括文件: “/usr/local/cuda/include/cuda_runtime_api.h”: No such file or directory error: command 'D:\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe' failed with exit status 2 在网上查询无果之后,问一下大佬怎么解决这个问题?

    opened by youngupup 0
  • 关于:AttributeError: 'ConfigDict' object has no attribute 'nms'问题,尝试解决,能跑了,会不会影响性能未知

    关于:AttributeError: 'ConfigDict' object has no attribute 'nms'问题,尝试解决,能跑了,会不会影响性能未知

    test_cfg = dict( rpn=dict( nms_across_levels=False, nms_pre=1000, nms_post=1000, max_num=1000, nms_thr=0.7, min_bbox_size=0), 在pre_process/assets/latest_version_cascade_rcnn_r101_fpn_1x.py当中找到如上代码块,加上如下两行,在min_bbox_size的上边加 nms=dict(type='nms', iou_threshold=0.7), max_per_img=100,

    opened by RuHaodong 2
  • 数据预处理出错(Data preprocessing error)

    数据预处理出错(Data preprocessing error)

    Hello, I am running Python extract_ bboxes. py --proj_ root=<path/to/project_ root> --dataset_ In the code name=ped2 --mode=train, I found that the length of the dataset I got was 0. Why there was no data. (你好,请问我在运行python extract_bboxes.py --proj_root=<path/to/project_root> --dataset_name=ped2 --mode=train这一代码时发现我得到的dataset的长度为0没有数据是什么原因。) image The problems are as follows (出现的问题如下所示) image

    opened by miracle-74 12
  • The pretrained model output AUC=0.5?

    The pretrained model output AUC=0.5?

    I use the same original dataset ped2, produce the flow, and the pretrained model, but both eval.py and ml_memAE_sc_eval.py output AUC=0.5, I'm confused. I debug the code, saw that a variable frame_bbox_scores in eval.py -> evaluate() only has data for the first 20.I don't know why.... frame_bbox_score

    opened by DaffTangEclipse 1
  • Reproducing on ped1&2

    Reproducing on ped1&2

    Hi, thanks for presenting your great work.

    I have a problem while reproducing the results on ped2 dataset, the AUC never reached 99% as mentioned in the paper. I got 97% after training, and after fine-tuning, AUC decreased to 95%. Also, it seems like the performance couldn't improve after the first epoch in training.

    I strictly followed the preprocessing steps and didn't change the configurations you provided. Do you have any suggestions regarding this issue? And also, have you tested the model on ped1 dataset, I wonder if there're any configurations differ from ped2.

    Thank you so much.

    opened by nono-zz 3
Owner
Computer Vision
null
A forwarding MPI implementation that can use any other MPI implementation via an MPI ABI

MPItrampoline MPI wrapper library: MPI trampoline library: MPI integration tests: MPI is the de-facto standard for inter-node communication on HPC sys

Erik Schnetter 31 Dec 22, 2022
ALBERT-pytorch-implementation - ALBERT pytorch implementation

ALBERT-pytorch-implementation developing... 모델의 개념이해를 돕기 위한 구현물로 현재 변수명을 상세히 적었고

BG Kim 3 Oct 6, 2022
Numenta Platform for Intelligent Computing is an implementation of Hierarchical Temporal Memory (HTM), a theory of intelligence based strictly on the neuroscience of the neocortex.

NuPIC Numenta Platform for Intelligent Computing The Numenta Platform for Intelligent Computing (NuPIC) is a machine intelligence platform that implem

Numenta 6.3k Dec 30, 2022
PyTorch implementation of neural style transfer algorithm

neural-style-pt This is a PyTorch implementation of the paper A Neural Algorithm of Artistic Style by Leon A. Gatys, Alexander S. Ecker, and Matthias

null 770 Jan 2, 2023
PyTorch implementation of DeepDream algorithm

neural-dream This is a PyTorch implementation of DeepDream. The code is based on neural-style-pt. Here we DeepDream a photograph of the Golden Gate Br

null 121 Nov 5, 2022
The project is an official implementation of our CVPR2019 paper "Deep High-Resolution Representation Learning for Human Pose Estimation"

Deep High-Resolution Representation Learning for Human Pose Estimation (CVPR 2019) News [2020/07/05] A very nice blog from Towards Data Science introd

Leo Xiao 3.9k Jan 5, 2023
Image-to-Image Translation with Conditional Adversarial Networks (Pix2pix) implementation in keras

pix2pix-keras Pix2pix implementation in keras. Original paper: Image-to-Image Translation with Conditional Adversarial Networks (pix2pix) Paper Author

William Falcon 141 Dec 30, 2022
Python implementation of cover trees, near-drop-in replacement for scipy.spatial.kdtree

This is a Python implementation of cover trees, a data structure for finding nearest neighbors in a general metric space (e.g., a 3D box with periodic

Patrick Varilly 28 Nov 25, 2022
Home repository for the Regularized Greedy Forest (RGF) library. It includes original implementation from the paper and multithreaded one written in C++, along with various language-specific wrappers.

Regularized Greedy Forest Regularized Greedy Forest (RGF) is a tree ensemble machine learning method described in this paper. RGF can deliver better r

RGF-team 364 Dec 28, 2022
Implementation of Restricted Boltzmann Machine (RBM) and its variants in Tensorflow

xRBM Library Implementation of Restricted Boltzmann Machine (RBM) and its variants in Tensorflow Installation Using pip: pip install xrbm Examples Tut

Omid Alemi 55 Dec 29, 2022
A fast Evolution Strategy implementation in Python

Evostra: Evolution Strategy for Python Evolution Strategy (ES) is an optimization technique based on ideas of adaptation and evolution. You can learn

Mika 251 Dec 8, 2022
🌳 A Python-inspired implementation of the Optimum-Path Forest classifier.

OPFython: A Python-Inspired Optimum-Path Forest Classifier Welcome to OPFython. Note that this implementation relies purely on the standard LibOPF. Th

Gustavo Rosa 30 Jan 4, 2023
Implementation of Geometric Vector Perceptron, a simple circuit for 3d rotation equivariance for learning over large biomolecules, in Pytorch. Idea proposed and accepted at ICLR 2021

Geometric Vector Perceptron Implementation of Geometric Vector Perceptron, a simple circuit with 3d rotation equivariance for learning over large biom

Phil Wang 59 Nov 24, 2022
Official implementation of AAAI-21 paper "Label Confusion Learning to Enhance Text Classification Models"

Description: This is the official implementation of our AAAI-21 accepted paper Label Confusion Learning to Enhance Text Classification Models. The str

null 101 Nov 25, 2022
Official PyTorch implementation for paper Context Matters: Graph-based Self-supervised Representation Learning for Medical Images

Context Matters: Graph-based Self-supervised Representation Learning for Medical Images Official PyTorch implementation for paper Context Matters: Gra

null 49 Nov 23, 2022
PyTorch implementation of "Conformer: Convolution-augmented Transformer for Speech Recognition" (INTERSPEECH 2020)

PyTorch implementation of Conformer: Convolution-augmented Transformer for Speech Recognition. Transformer models are good at capturing content-based

Soohwan Kim 565 Jan 4, 2023
An essential implementation of BYOL in PyTorch + PyTorch Lightning

Essential BYOL A simple and complete implementation of Bootstrap your own latent: A new approach to self-supervised Learning in PyTorch + PyTorch Ligh

Enrico Fini 48 Sep 27, 2022
The official implementation of NeMo: Neural Mesh Models of Contrastive Features for Robust 3D Pose Estimation [ICLR-2021]. https://arxiv.org/pdf/2101.12378.pdf

NeMo: Neural Mesh Models of Contrastive Features for Robust 3D Pose Estimation [ICLR-2021] Release Notes The offical PyTorch implementation of NeMo, p

Angtian Wang 76 Nov 23, 2022
A PyTorch re-implementation of the paper 'Exploring Simple Siamese Representation Learning'. Reproduced the 67.8% Top1 Acc on ImageNet.

Exploring simple siamese representation learning This is a PyTorch re-implementation of the SimSiam paper on ImageNet dataset. The results match that

Taojiannan Yang 72 Nov 9, 2022