DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Three Awesome TensorFlow.js Models for Visual Recognition

Three Awesome TensorFlow.js Models for Visual Recognition

Explore three TensorFlow.js models for visual recognition.

Niklas Heidloff user avatar by
Niklas Heidloff
CORE ·
Jan. 30, 19 · Tutorial
Like (3)
Save
Tweet
Share
11.04K Views

Join the DZone community and get the full member experience.

Join For Free

last week, i open sourced a web application called blue cloud mirror , which is a game where players need to show five specific emotions and do five specific poses in two levels. the faster, the better.

you can play the game online ; it only takes a minute. all you need is a webcam and a chrome browser.

the game uses three different tensorflow.js models for visual recognition. the code is executed in browsers to run predictions, which are pretty fast.

faces

face-api.js can detect faces, find face similarities and detect face landmarks. try the online demo .

emotions

face_classification predicts emotions and can identify genders. the output of face-api.js is passed into this model. try the online demo .

poses

posenet can detect 17 key points of bodies and works for single persons and multiple persons. try the online demo .

using the models in vue.js

the usage of the models in vue.js is pretty straight forward. here is the code to load and run the emotions model.

<script>
import * as tf from "@tensorflow/tfjs";

export default {
  name: "emotionmodel",
  data() {
    return {
      model: {}
    };
  },
  mounted() {
    let url = "models/emotion/model.json";
    tf.loadmodel(url).then(result => {
      this.model = result;
...
   var r = this.model.predict(input);
   var result = r.datasync();
   var tresult = tf.tensor(result);
   var label_index = tf.argmax(tresult).datasync()[0];
   var label_percent = result[label_index].tofixed(4) * 100;
...
</script>

if you want to run everything from your local machine, run these commands:

$ git clone https://github.com/ibm/blue-cloud-mirror.git
$ cd blue-cloud-mirror/game
$ yarn install
$ yarn run serve

this is a screenshot of level one of the game where five different emotions need to be shown.

thanks, and let me know what you think in the comments section!

Awesome (window manager) Web application code style Vue.js Mirror (programming) Command (computing) Machine Cloud

Published at DZone with permission of Niklas Heidloff, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Kubernetes vs Docker: Differences Explained
  • Easy Smart Contract Debugging With Truffle’s Console.log
  • What Is Policy-as-Code? An Introduction to Open Policy Agent
  • An Introduction to Data Mesh

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: