Goal is to recognize hand gestures. I've trained the model on my own dataset using Perceptron (and CNN thereafter). I've included my dataset in the repository itself. In it's present state the model is trained to recognize just two (now four) gestures (please see the CNN implementation section in this readme, I trained it for 4 gestures afterwards) but can easily be trained for many hand gestures. I'll also upload the code that I'm using for capturing the hand an processing it for training the model.
Model gives a high testing accuracy of about 99% using just two Dense layers. But if you want to train more hand gestures then you'll probably need more a complex network.
Images in the dataset are of dimension 200 by 200. But for performance reasons they have been resized to 50 by 50. You can use them as it is if you have a powerful setup otherwise program displays a Tensorflow error
tensorflow/core/framework/allocator.cc:101] Allocation of X exceeds 10% of system memory.
captureHand.py
- This program can capture new hand gestures and write them in the specified directoryrecognizer.py
- This is the main program that uses pretrained model (in the repo) for recognizing hand gesturestrainer.py
- This program uses the given dataset to train the Perceptron modelmodelWeights.h5
- Weights for the Perceptron modeltrainedModel.json
- JSON format of the modelCNN Model
- A directory that contains CNN model implementation for the same recognition purpose (with 4 gestures)
- First Hand Gesture
- Second Hand Gesture
cv2 (opencv)
imutils
glob
sklearn (scikit-learn)
keras
numpy
- For the first gesture
- For the second gesture
I hope to implement more than two gestures in the future. There will be further improvements in the code itself too.
As of May 1, 2019 I have used CNN for the recognition of 4 gestures. All the required files are present in the folder CNN Model
.
- CNN Training Output
- Perceptron Training Output
I've used both the Perceptron as well as the CNN Model for recognition of 4 hand gestures. And I can easily say CNN works better for extracting features of an image. There's and improvement of Error %age from 32% to 5%. This happens because Perceptron model is a simple 1 dimensional set of neurons, therefore it reduces a lot of features in the images whereas the CNN is specially designed to work with images and works on 2 dimensional set of neurons. You can read more about the algorithms online.