Coder Social home page Coder Social logo

mohamedsebaie / fight_detection_from_surveillance_cameras-pytorch_project Goto Github PK

View Code? Open in Web Editor NEW
32.0 6.0 10.0 212.63 MB

Fight Detection From Surveillance Cameras by fine-tuning a PyTorch Pretrained Model

Home Page: https://pypi.org/project/Fight-Detection/0.0.3/

License: MIT License

Python 0.46% Jupyter Notebook 99.54%
pytorch resnet-18 3dcnn streaming pretrained-models pretrained-weights pytorch-implmention pytorch-cnn computer-vision transfer-learning finetuning surveillance cctv-cameras cctv-detection fight-detection

fight_detection_from_surveillance_cameras-pytorch_project's Introduction

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)

fight_detection_from_surveillance_cameras-pytorch_project's People

Contributors

abdullahabdelhakeem6484 avatar atefel-hennawy avatar elshaimaa avatar mohamedhamayed avatar mohamedsebaie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fight_detection_from_surveillance_cameras-pytorch_project's Issues

infer error

when I run the code python -m infer --modelPath="./Models/model_16_m3_0.8888.pth" --streaming=False --inputPath='/mnt/Data/ProjectCode/fightDetection/Fight_Detection_From_Surveillance_Cameras-PyTorch_Project/dataset/fight/fi001.mp4' --outputPath="./outputVideo.mp4" --sequenceLength=16 --skip=2
I get that error:
Traceback (most recent call last): File "/home/dong/.conda/envs/fightDetection/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/home/dong/.conda/envs/fightDetection/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/mnt/Data/ProjectCode/fightDetection/Fight_Detection_From_Surveillance_Cameras-PyTorch_Project/infer.py", line 35, in <module> main() File "/mnt/Data/ProjectCode/fightDetection/Fight_Detection_From_Surveillance_Cameras-PyTorch_Project/infer.py", line 25, in main start_streaming(model, args.inputPath) File "/mnt/Data/ProjectCode/fightDetection/Fight_Detection_From_Surveillance_Cameras-PyTorch_Project/FDSC/Fight_utils.py", line 461, in start_streaming cv2.imshow("RTSP", frame) cv2.error: OpenCV(4.6.0) /io/opencv/modules/highgui/src/window.cpp:967: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'

It seems occurred some error, than no frame return. So get that error. Could you help me to solve it.

Request for Guidance on Fine-Tuning the Model on Custom Datasets

Thank you for sharing this great project! It has been incredibly useful for my work.

I would like to ask if you could provide some guidance or code examples on how to fine-tune the existing model on custom datasets. Specifically, I'm interested in:

Thank you in advance for your help!

permission denied to access google drive link

Access denied with the following error:

Cannot retrieve the public link of the file. You may need to change
the permission to 'Anyone with the link', or have had many accesses. 

You may still be able to access the file from the browser:

 https://drive.google.com/uc?id=1MWDeLnpEaZDrKK-OjmzvYLxfjwp-GDcp 

ModuleNotFoundError: No module named 'FDSC'

I run
python -m infer
--modelPath="./Models/model_16_m3_0.8888.pth"
--streaming=False
--inputPath="./dataset/fight/fi148.mp4"
--outputPath="./outputVideo.mp4"
--sequenceLength=16
--skip=2
--showInfo=True

get this error!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.