Giter Site home page Giter Site logo

hypermit / visual-recognition-for-cozmo-with-tensorflow Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ibm/visual-recognition-for-cozmo-with-tensorflow

0.0 2.0 0.0 13.55 MB

Visual Recognition for Anki Cozmo with TensorFlow

Home Page: https://visual-recognition-for-cozmo-with-tensorflow.mybluemix.net/

License: Apache License 2.0

Python 4.66% Shell 0.48% JavaScript 41.59% CSS 41.87% HTML 11.40%

visual-recognition-for-cozmo-with-tensorflow's Introduction

Visual Recognition for Anki Cozmo with TensorFlow

The Anki Cozmo robot can recognize faces and objects like Cozmo's Power Cubes which have markers on them. This project contains sample code so that Cozmo can recognize other types of objects via TensorFlow.

Watch the video and check out the slides to see how Cozmo can recognize three different toys:

Video

Authors:

Documentation

The training is done via TensorFlow and a retrained MobileNet model on Kubernetes.

alt text

The classification is done via Tensorflow running in an OpenWhisk function.

alt text

For more details check out the blog entries from Ansgar and me:

Prerequisites

Install the Cozmo SDK.

Get a free IBM Cloud lite account.

Install the IBM Cloud/Bluemix CLI.

Install Docker.

Create a free/lite Kubernetes cluster.

Install the Kubernetes CLI.

1. Take Pictures

Take pictures of an object by invoking these commands and circling Cozmo around the object for 10 seconds. Replace 'deer' with a name for your object:

$ git clone https://github.com/nheidloff/visual-recognition-for-cozmo-with-tensorflow.git
$ cd visual-recognition-for-cozmo-with-tensorflow/1-take-pictures
$ python3 take-pictures.py deer

2. Upload Pictures

Create an IBM Object Storage instance. Choose the lite Swift option. Read Ansgar's blog for details.

Copy/remember the IBM Object Storage credentials: ‘region’, ‘projectId’, ‘userId’ and ‘password’. Paste them in upload-pictures.py.

Invoke these commands:

$ cd visual-recognition-for-cozmo-with-tensorflow/2-upload-pictures
$ pip3 install python-swiftclient
$ pip3 install python-keystoneclient
$ python3 upload-pictures.py

3. Train the Model

Paste the values of ‘region’, ‘projectId’, ‘userId’ and ‘password’ in train.yml.

Replace 'nheidloff' with your DockerHub name and run these commands:

$ cd visual-recognition-for-cozmo-with-tensorflow/3-train
$ docker build -t nheidloff/tensorflow-openwhisk-train-cozmo:latest .
$ docker push nheidloff/tensorflow-openwhisk-train-cozmo:latest
$ bx login -a api.ng.bluemix.net
$ bx cs cluster-config mycluster
$ export KUBECONFIG=/Users/nheidlo.....
$ kubectl apply -f train.yml 

After this you should see the files 'retrained_graph_cozmo.pb' and 'retrained_labels_cozmo.txt' in the 'tensorflow' container in IBM Object Storage.

Read Ansgar's blog for more details.

4. Deploy the Model to OpenWhisk

Paste the values of ‘region’, ‘projectId’, ‘userId’ and ‘password’ in classifier.py.

Replace 'nheidloff' with your DockerHub name and run these commands:

$ cd visual-recognition-for-cozmo-with-tensorflow/4-classify
$ docker build -t nheidloff/tensorflow-openwhisk-classifier-cozmo:latest .
$ docker push nheidloff/tensorflow-openwhisk-classifier-cozmo:latest
$ cd visual-recognition-for-cozmo-with-tensorflow/4-classify/openwhisk-api
$ bx login -a api.ng.bluemix.net
$ bx target -o <your-organization> -s <your-space>
$ bx plugin install Cloud-Functions -r Bluemix
$ wsk package create visualRecognitionCozmo
$ wsk action create visualRecognitionCozmo/tensorflow-classify --docker nheidloff/tensorflow-openwhisk-classifier-cozmo:latest
$ npm install
$ sh ./deploy.sh
$ wsk action create --sequence visualRecognitionCozmo/classifyAPI visualRecognitionCozmo/classifyImage,visualRecognitionCozmo/tensorflow-classify --web raw

5. Test the Model via the Web Application

In the OpenWhisk web application choose your sequence and open 'Additional Details'. From there copy the URL into the clipboard. Create a new file '.env' in the '5-test-in-web-app' directory. See .env-template for an example. Paste the URL in this file.

From the directory 'web-app' run these commands:

$ cd visual-recognition-for-cozmo-with-tensorflow/5-test-in-web-app
$ npm install
$ npm start

Open the web application via http://localhost:3000/.

Optionally: In order to deploy the application to the IBM Cloud, change the application name in manifest.yml to something unique and run these commands:

$ bx login -a api.ng.bluemix.net
$ bx target -o <your-organization> -s <your-space>
$ cf push

Open the web application via http://your-application-name.mybluemix.net/.

6. Test Visual Recognition with Cozmo

Place your object(s) in a circle around Cozmo and run these commands. Replace 'deer' with a name for your object:

$ cd visual-recognition-for-cozmo-with-tensorflow/6-play-with-cozmo
$ python3 find.py deer

visual-recognition-for-cozmo-with-tensorflow's People

Contributors

nheidloff avatar

Watchers

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