[Sorry, this codebase is no longer maintained! But the codes would still be useful for building video recognition deep learning pipelines. There might be some bugs and missing links to datasets (please collect data from the original source of these public datasets)!]
This repository contains the codes for our [PAPER] on violence detection titled Efficient Two-Stream Network for Violence Detection Using Separable Convolutional LSTM which is accepted to be presented at Int'l Joint Conference on Neural Networks (IJCNN) 2021.
To get RWF2000 dataset,
- go to github.com/mchengny/RWF2000-Video-Database-for-Violence-Detection
- sign their agreement sheet to get the download link from them.
- prepare the downloaded dataset like the following folder structure,
📦project_directory
┣ 📂RWF-2000
┣ 📂train
┣ 📂fight
┣ 📂nonFight
┣ 📂test
┣ 📂fight
┣ 📂nonFight
- When running train.py for the first time, pass the argument --preprocessData, this will uniformly sample 32 frames from each video, remove black borders and save them as .npy files. During the next times no need to pass the argument --preprocessData, as you already have converted the videos into .npy files during the first time.
Hockey and Movies dataset can be downloaded from these links -
Then, preprocess the datasets in the same way as rwf2000 dataset.
To train models go to project directory and run train.py like below,
python train.py --dataset rwf2000 --vidLen 32 --batchSize 4 --numEpochs 150 --mode both --preprocessData --lstmType sepconv --savePath FOLDER_TO_SAVE_MODELS
The training curves and history will be saved in ./results and updated after every epoch.
To evaluate an already trained model, use evaluate.py like below,
python evaluate.py --dataset rwf2000 --vidLen 32 --batchSize 4 --mode both --lstmType sepconv --fusionType M --weightsPath PATH_TO_SAVED_MODEL
this will save the results in test_results.csv.
The trained models weigths are available in the drive folder trained_models. Copy the model you want to use into your project directory like shown below. Then you can evaluate the trained_model like below.
python evaluate.py --dataset rwf2000 --vidLen 32 --batchSize 4 --mode both --lstmType sepconv --fusionType M --weightsPath "/content/violenceDetection/model/rwf2000_model"
The trained models weigths are available in the drive folder trained_models. Copy the entire folder and its contents into the project directory. Then you can use the trained models like shown below.
path = "./trained_models/rwf2000_model/sepconvlstm-M/model/rwf2000_model"
# path = "./trained_models/movies/sepconvlstm-A/model/movies_model"
model = models.getProposedModelM(...) # build the model
model.load_weights(path) # load the weights
The folder also contains training history, training curves and test results.
Python 3.7, Tensorflow 2.3.1, OpenCV 4.1.2, Numpy, Matplotlib, sci-kit learn
pip install -r requirements.txt
If you do use ideas from the paper in your work please cite as below:
@misc{islam2021efficient,
title={Efficient Two-Stream Network for Violence Detection Using Separable Convolutional LSTM},
author={Zahidul Islam and Mohammad Rukonuzzaman and Raiyan Ahmed and Md. Hasanul Kabir and Moshiur Farazi},
year={2021},
eprint={2102.10590},
archivePrefix={arXiv},
primaryClass={cs.CV}
}