GithubHelp home page GithubHelp logo

prasadashu / rock-paper-scissor-playpal Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 10.26 MB

A CNN based project wherein the neural network attempts to classify the gesture made by the hand as either rock, paper or scissor and consequently takes a decision of its own to compete with the player

Python 100.00%

rock-paper-scissor-playpal's Introduction

Rock Paper Scissor Playpal

This is my first CNN based project wherein I train a neural network that attempts to classify the gesture made by the hand as either rock, paper or scissor. The computer (or pal!) makes a choice of its own by choosing among the three i.e. rock, paper or scissor and consequently competes with the player.

capture_training_data.py

The above file upon execution accesses the video camera on the client system to capture images of the users hand gestures which serves as the training set for the deep learning algorithm. One can edit the path in the file to save the images in the desired location. By default all images captured get stored in the image directory. The images captured are stored in a 28x28 pixel format.

creating_dataset.py

This file runs on the premise that the images of the hand gestures for each of the classes is stored in the respective(class name) directory within the image directory. It converts the images into a 784x1 vector and labels each image with a class identifier. Scissor is marked as 2, Rock as 1 and Paper as 0. The vectors along with the labels are stored in the form of a dataframe and stored in the created_dataset directory.

cnn_model.py

This contains the CNN model. The image data is retrieved from the dataset and passed through the model. Finally the model is exported and saved in the home directory by the name synthetic_pmate(just liked the name!) in an h5 format.

predict_realtime_data.py

Finally, upon execution of the above file, the video camera feed is captured and the gestures made by the hand is attempted to be classified as one of the three classes. The predicted class can be viewed in the console. The program runs in an infinite loop and can be terminated by pressing the esc key. The file imports the synthetic_pmate.h5 model and passes each image through it after reshaping it again into a 28x28 pixel format.

synthetic_pmate.h5

As stated above, this contains the model exported by the cnn_model.py file. This is a practice of model deployment wherein one mustn't train the entire network, instead a pre-trained model is used to predict the classes of the images.

Note:

In order to execute the code, one must run only the predict_realtime_data.py file. Do rename the path in the file for the saved model if any error occurs.

Dependencies

  • Numpy
  • Pandas
  • Keras
  • Sklearn
  • OpenCV
  • OS
  • Matplotlib(Only for visualization purpose)

rock-paper-scissor-playpal's People

Contributors

prasadashu avatar

Stargazers

Garvit Kothari avatar

Watchers

James Cloos 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.