Code Monkey home page Code Monkey logo

violence-detection-vit-b-32's Introduction

Table of Contents

Introduction

How to Run

Resutls

Further Work

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:

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 video

Result video

Result Images

Result image Result image Result image Result image Result image Result image Result image

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: Soso Sukhitashvili

violence-detection-vit-b-32's People

Contributors

sukhitashvili avatar

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.