Pytorch implementation of video anomaly detection paper for CVPR 2018: Future Frame Prediction for Anomaly Detection – A New Baseline.
Most codes were obtained from the following GitHub page: [Link]
To understand the code, please refer to the Google Colab page (Korean): [Link]
I only trained the ped2
dataset, the result:
AUC |
USCD Ped2 |
original implementation |
95.4% |
this implementation |
95.5% |
![ffp_pipe](https://private-user-images.githubusercontent.com/52392658/272521175-e9ce53b3-6c6f-453e-8b63-b05629c8b9d9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU2NTc0NzIsIm5iZiI6MTcyNTY1NzE3MiwicGF0aCI6Ii81MjM5MjY1OC8yNzI1MjExNzUtZTljZTUzYjMtNmM2Zi00NTNlLThiNjMtYjA1NjI5YzhiOWQ5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA2VDIxMTI1MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdkMWQ0OWNmYjdiZmQwNTQyYmE4Y2Q0ZjAyYTAzNzJiZTkzZTIzMGE0MGQzMWI4YmJlZTE5ODFmMTdmNGM0YzYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.au2gaPnqk0Bi9NDYSJ7C5iJiHnBVFG3IBTBd-5V8b20)
PyTorch >= 1.1.
Python >= 3.6.
opencv
sklearn
Other common packages.
- Download the ped2 dataset and put it under the
data
folder.
- Download the FlowNet2-SD weight and put it under the
flownet/pretrained
folder.
- Download the trained model and put it under the
weights
folder.
# default option.
python train.py --dataset=ped2
# change 'seed'.
python train.py --dataset=ped2 --manualseed=50
# change 'max iteration'.
python train.py --dataset=ped2 --iters=60000
# change 'model save interval'.
python train.py --dataset=ped2 --save_interval=10000
# change 'validation interval'.
python train.py --dataset=ped2 --val_interval=1000
# Continue training with latest model
python train.py --dataset=ped2 --resume=latest_ped2
# default option.
python eval.py --dataset=ped2 --trained_model=best_model_ped2
# change 'show heatmap'.
python eval.py --dataset=ped2 --trained_model=best_model_ped2 --show_heatmap=True
# change 'show roc_curve'.
python eval.py --dataset=ped2 --trained_model=best_model_ped2 --show_curve=True
Validation results can be found on the path results
by AUC graph.
AUC graph (ped2) |
![auc_graph](https://github.com/SkiddieAhn/SkiddieAhn/assets/52392658/9c031b26-170a-4cf0-acee-bcd121e3f601?raw=true) |
Evaluation results can be found on the path results/ped2/{best_iter}
by ROC Curve, Anomaly Score, etc.
ROC Curve with AUC (ped2) |
![toal_auc_curve](https://github.com/SkiddieAhn/SkiddieAhn/assets/52392658/98443208-415d-4723-b78d-e8296766de32?raw=true) |
Anomaly Score (ped2-04) |
![score_graph](https://github.com/SkiddieAhn/SkiddieAhn/assets/52392658/dfe6d801-112e-4189-b315-a8c3981c67b5?raw=true) |
Frame Comparison (ped2-04) |
![ffp_comparision](https://github.com/SkiddieAhn/SkiddieAhn/assets/52392658/0c299ee4-7e40-495f-abf9-c7f7e11280cb?raw=true) |
- Frame-Prediction lecture note: [Link] (24.04.18)