Skip to content

Real time violence, fire and human presence detection

License

Notifications You must be signed in to change notification settings

aditisharma132/SP_Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This repo presents code for a deep-learning-based algorithm for detecting violence, fire and human presence in indoor or outdoor environments. The algorithm can accurately detect the following scenarios: fight, fire, car crash, and even more.

To detect other scenarios you have to add descriptive text label of a scenario in settings.yaml file under labels key. At this moment model can detect 16+1 scenarios, where one is default Unknown label. You can change, add or remove labels according to your use case. The model is trained on wide variety of data. The task for the model at training was to predict similar vectors for image and text that describes well a scene on the image. Thus model can generalize well on other scenarios too if you provide proper textual information about a scene of interest.

How to Run

First install requirements: pip install -r requirements.txt

Dataset can be taken from:

https://github.com/sukhitashvili/violence-detection/tree/main/data

https://drive.google.com/open?id=1qpnajiy9wa5dZStqIhFHVgy2hE_fK4fb

To test the model you can either run: python run.py --image-path ./data/7.jpg

Or you can test it through web app: streamlit run app.py

Or you can see the example code in tutorial.ipynb jupyter notebook

Or incorporate this model in your project using this code:

from model import Model
import cv2

model = Model()
image = cv2.imread('./your_image.jpg')
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
label = model.predict(image=image)['label']
print('Image label is: ', label)

Results

Below are the resulting images. I used the model to make predictions on each frame of the videos and print model's predictions on the left side of frame of saved videos. In case of images, titles are model's predictions. You can find code that produces that result in tutorial.ipynb jupyter notebook.

Result Images

WhatsApp Image 2024-04-24 at 4 15 09 PM WhatsApp Image 2024-04-24 at 4 40 14 PM Screenshot 2024-04-23 210344 Screenshot 2024-04-23 210354 Screenshot 2024-04-23 210933

Screenshot 2024-04-24 163430 Screenshot 2024-04-24 163335

Further Work

For further enhancements like: Batch processing support for speedup, return of multiple suggestions, threshold fine-tuning for specific data, ect. contact me:

My Linkedin: ![Aditi Sharma][https://www.linkedin.com/in/aditi-sharma-663709202/]

About

Real time violence, fire and human presence detection

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages