Skip to content

MohamedSebaie/Fight_Detection_From_Surveillance_Cameras-PyTorch_Project

Repository files navigation

Fight Detection Project


Video_app.online-video-cutter.com.mp4
Video_app.online-video-cutter.com.1.mp4

Abstract

Vision-based activity recognition is one of the most challenging research topics of computer vision and pattern recognition. A specific application of it, namely, detecting fights from surveillance cameras in public areas, prisons, etc., is desired, to get violent incidents under control quickly to reduce casualties.

Results

Model Top-1 Accuracy Batch Size (Videos) Input Frames Recall (Fight) Inference Rate (Videos/sec)
r2plus1d_18 77.5% 4 16 0.75 10
r3d_18 82.5% 4 16 0.85 10
mc3_18 90% 4 16 0.80 10
mc3_18 92.5% 8 16 0.90 10
mc3_18 85% 4 32 0.90 5.7

Pytorch Pretrained Models

All pretrained models can be found in this link. https://pytorch.org/vision/stable/models.html

Confusion Matrix

Simply Easy Learning

Inference

Run the infer.py script and pass the required arguments (modelPath, streaming, inputPath, outputPath, sequenceLength, skip, showInfo)

python -m infer \
--modelPath="./FDSC/models/model_16_m3_0.8888.pth" \
--streaming=False \
--inputPath="./inputTestVideo.mp4" Or Streaming Url in case of streaming = True \
--outputPath="./outputVideo.mp4" \
--sequenceLength=16 \
--skip=2 \
--showInfo=True


Instructions to Install our Fight Detection Package

Our Package can be found in this link. https://pypi.org/project/Fight-Detection/0.0.3/

  1. Install:
pip install Fight-Detection==0.0.3
pip install pytube
  1. Download Our Finetuned Model Weights:
import gdown
url = 'https://drive.google.com/uc?id=1MWDeLnpEaZDrKK-OjmzvYLxfjwp-GDcp'
output = 'model_16_m3_0.8888.pth'
gdown.download(url, output, quiet=False)
  1. Detect Fight or Not by Pass your Local Video:
from fight_detection import Fight_utils
# Run the Below Function by Input your Test Video Path to get the outPut Video with Fight Detection or Not
Fight_utils.fightDetection(inputPath,seq,skip,outputPath,showInfo)
  1. Show the Output Video with Detection:
from moviepy.editor import *
VideoFileClip(outputPath, audio=False, target_resolution=(300,None)).ipython_display()

5- Detect the Fight on Streaming:

Fight_utils.start_streaming(streamingURL)