https://github.com/sukhitashvili/violence-detection
Deep learning based algorithm which is capable of detecting violence in indoor or outdoor environments: fight, fire or car crash and even more
https://github.com/sukhitashvili/violence-detection
car-accidents-detection classification-model deep-learning fire-detection violence-detection
Last synced: 3 months ago
JSON representation
Deep learning based algorithm which is capable of detecting violence in indoor or outdoor environments: fight, fire or car crash and even more
- Host: GitHub
- URL: https://github.com/sukhitashvili/violence-detection
- Owner: sukhitashvili
- Created: 2021-10-03T20:36:49.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-12-31T12:07:00.000Z (over 1 year ago)
- Last Synced: 2025-05-20T00:06:42.624Z (about 1 year ago)
- Topics: car-accidents-detection, classification-model, deep-learning, fire-detection, violence-detection
- Language: Jupyter Notebook
- Homepage:
- Size: 46.2 MB
- Stars: 80
- Watchers: 1
- Forks: 24
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Table of Contents
[Introduction](#introduction)
[How to Run](#howtorun)
[Resutls](#results)
# Introduction
This repo presents code for Deep Learning based algorithm for
**detecting violence** in indoor or outdoor environments. The algorithm can
detect following scenarios with high accuracy: 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`
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:
```python
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 videos and 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







# Further Work
Needs further work for enhancements like: Batch processing support for speedup, return of
multiple suggestions, threshold fine-tuning for specific data, ect.