In this project, an ML model will predict directions from an image in web camera. We can fine-tune a pretrained MobileNet model to predict 4 different classes (i.e, up, down, left, right) as defined by the user.
Check out the Live Demo
- Add Example: Use your web camera to provide example images for the four different classes (up, down, left, right).
- Train: Fine-tune the ML model with these images.
- Play: Start playing Pac-Man by making gestures in front of your web camera.
- Ensure you have a code IDE like VSCode installed. VSCode is recommended, but feel free to use any IDE of your choice.
- Install npm on your machine.
- (If you are familar with Github)
fork
this repository, andclone
the forked repository to your local machine. Learn how to fork and clone. - (If you are not familar with Github) directly download the code from this repo
- Open the cloned project folder with VSCode.
- Launch the VSCode integrated terminal from menu:
Terminal > New Terminal
orView > Terminal
. - In the terminal, run
npm install
to install necessary npm packages (first-time setup only).
Execute npm run watch
in the terminal.
The project will open in your default web browser. Any code changes will automatically update the webpage. Google Chrome is recommended for the development.
Run npm run deploy
in your terminal
- In your web browser, go to the forked project in your github, and select the "Settings" tab.
- In the sidebar, under "Code and automation," choose "Pages."
- Set up "Build and deployment" as follows:
- Source:
Deploy from a branch
- Branch:
gh-pages
; Folder:/ (root)
- Source:
- Click "Save."
You can now share this demo via https://{your_github_userid}.github.io/tfjs-webcam-ML-PACMAN/
This project is a modified version based on the official TensorFlow.js demos. For more information and additional context, visit TensorFlow.js Demos.