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 frontbehind
- To stop vehicles coming from behindfrandbk
- To stop vehicles simultaneously from front and behindclose
- Warning signal closing all vehicles.
- 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
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
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:*
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.