Giter Site home page Giter Site logo

cyber-machine / trafficsense Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 15.33 MB

Computer Vision model for identifying police hand signals using TensorFlow & Tensorflow-lite.

License: MIT License

Dockerfile 0.24% Jupyter Notebook 68.15% Python 31.61%
computer-vision movenet-thunder opencv pose-estimation python3 tensorflow tensorflow-lite

trafficsense's Introduction

TrafficSense

This repository contains a computer vision model for identifying police hand signals using TensorFlow & Tensorflow-lite. The model is trained on a custom dataset of images demonstrating various hand signals and achieves an accuracy of ~86% on the test set.

Various techniques have been used to improve upon the model's accuracy such as Data Augmentation, Dropout, validation sets, etc.

Pose Detection was identified by movenet-thunder model which is lighter and achieves a realtime detection. Classification of poses was done on a custom layered Neural Network.

A TensorFlow-lite model is also created using quantization and pruning, achieving similar accuracy with just a fraction of the original model size (26KB). This can be used in IoT devices like Raspberry Pi / Arduino for detection.

It can classify between four poses :

  • front - To stop vehicles coming from front
  • behind - To stop vehicles coming from behind
  • frandbk - To stop vehicles simultaneously from front and behind
  • close - Warning signal closing all vehicles.

Libraries Used

  • TensorFlow - Used for model training and inference
  • Numpy - Used for array manipulation
  • OpenCV - Used for image preprocessing and display
  • Tensorflow-lite - Used for model deployment on edge devices
  • Docker - Used for model deployment on DockerHub

Run Locally

Run on system

Clone the project

  git clone https://github.com/Cyber-Machine/TrafficSense

Go to the project directory

  cd TrafficSense

Install libraries

  pip install -r requirements.txt

Run python file

  python detect.py

Run via Docker

In order to run this model through docker allow X server connection to access display.

Pull image from dockerhub

docker pull cybermachine/trafficsense

On Terminal run

# Allow X server connection
xhost +local:*

And now run the app on docker

 docker run --rm -it --device /dev/video0 -e "DISPLAY=$DISPLAY" -v /tmp/.X11-unix/:/tmp/.X11-unix/ cybermachine/trafficsense:latest

Press ESC to close the screen.

Also revoke access to X server connection after use.

# Disallow X server connection
xhost -local:*

Run Remotely

In order to run this model on remotely, upload TrafficSense_Colab.ipynb to Google Colab and run all the cells.

Output is generated as output.mp4 inside TrafficSense folder in colab.

trafficsense's People

Contributors

cyber-machine avatar

Watchers

 avatar  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.