Chapter 10. AI in the Browser with TensorFlow.js and ml5.js

You’re a developer who dreams big. You have a kickass AI model that you would like a lot of people to try. How many is a lot? Ten thousand? A million? No, silly. You like to dream big. How about 100 million people? That’s a nice round number. Now convincing 100 million people to download and install an app and make space for it on their phones is not an easy sell. But what if we told you that they all have an app already installed, just for you. No downloads. No installs. No app stores. What kind of black magic is this!? Of course, it’s the web browser. And as a bonus, it also runs on your PC.

This is what Google did with its home page when it decided to launch its first-ever AI doodle to their billions of users (Figure 10-1). And what better theme to pick for it than the music of J.S. Bach. (Bach’s parents wanted to call him J.S. Bach, 310 years before JavaScript was even created. They had quite the foresight!)

To explain briefly, the doodle allowed anyone to write one line (voice) of random notes for two measures using mouse clicks. When the user clicked a button labeled Harmonize, the input would then be processed against hundreds of musical pieces written by Bach that contain between two and four lines (voices) of music. The system would figure out which notes would sound best along with the user’s input to create a much richer Bach-like sounding musical piece. ...

Get Practical Deep Learning for Cloud, Mobile, and Edge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.