{"id":312,"date":"2018-06-11T16:47:55","date_gmt":"2018-06-11T16:47:55","guid":{"rendered":"https:\/\/itp.nyu.edu\/adjacent\/issue-3\/?p=312"},"modified":"2024-10-08T20:28:41","modified_gmt":"2024-10-08T20:28:41","slug":"ml5-friendly-open-source-machine-learning-library-for-the-web","status":"publish","type":"post","link":"https:\/\/itp.nyu.edu\/adjacent\/issue-3\/ml5-friendly-open-source-machine-learning-library-for-the-web\/","title":{"rendered":"ml5: Friendly Open Source Machine Learning Library for the Web"},"content":{"rendered":"<blockquote><p><span style=\"font-weight: 400;\">Technology is not enough. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Consider the technology as a tool which, in itself, could do nothing.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Treat the technology as something that everyone on the team could learn, understand, and explore freely.<\/span><\/p>\n<p style=\"text-align: right;\"><span style=\"font-weight: 400;\"> \u00a0&#8212; Red Burns<\/span><\/p>\n<\/blockquote>\n<p><span style=\"font-weight: 400;\">Each fall at ITP, many students with a variety of backgrounds from all over the world see code for the first time in a course called \u201cIntroduction to Computational Media\u201d.\u00a0This is not a computer science course, rather it is a course about learning to think computationally and apply computation to one\u2019s passion whether that be art, dance, biology, social justice, fashion, and more. There are no tests, nor algorithms to memorize, only creative projects to make and the sole requirement is to simply give it a try. This is a key mission of ITP \u2014 find ways to make technology and coding more accessible and inclusive, s<\/span><span style=\"font-weight: 400;\">omething that everyone can learn, understand, and explore freely and creatively.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-392\" src=\"https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/MachineLearning.gif\" alt=\"An animated comic should a computer in a drawing class learning how to draw a cat.\" width=\"792\" height=\"432\" \/><\/p>\n<p><span style=\"font-weight: 400;\">The primary vehicle for the introductory course is <\/span><a href=\"https:\/\/p5js.org\/\"><span style=\"font-weight: 400;\">p5.js<\/span><\/a><span style=\"font-weight: 400;\">, a JavaScript library from <\/span><a href=\"https:\/\/processingfoundation.org\/\"><span style=\"font-weight: 400;\">The Processing Foundation<\/span><\/a><span style=\"font-weight: 400;\"> whose mission aligns with the course: <\/span><span style=\"font-weight: 400;\">\u201cto empow<\/span><span style=\"font-weight: 400;\">er people of all interests and backgrounds to learn how to program and make creative work with code, especially those who might not otherwise have access to these tools and resources.\u201d Casey Reas and Ben Fry, in <\/span><a href=\"https:\/\/medium.com\/@ProcessingOrg\/a-modern-prometheus-59aed94abe85\"><span style=\"font-weight: 400;\">A Modern Prometheus: The History of Processing<\/span><\/a><span style=\"font-weight: 400;\">, write:<\/span><\/p>\n<blockquote><p><span style=\"font-weight: 400;\">The original mission of Processing was to create software that made learning to code accessible for visual people (designers, artists, architects) and to help a more technical audience work fluidly with graphics. We aspired to empower people to become software literate\u200a\u2014\u200ato learn to <\/span><i><span style=\"font-weight: 400;\">read<\/span><\/i><span style=\"font-weight: 400;\"> and <\/span><i><span style=\"font-weight: 400;\">write<\/span><\/i><span style=\"font-weight: 400;\"> software. We wanted to change curriculum in universities and art schools around the world. Instead of teaching students how to <\/span><i><span style=\"font-weight: 400;\">use<\/span><\/i><span style=\"font-weight: 400;\"> software, we thought it was just as important to teach them how to <\/span><i><span style=\"font-weight: 400;\">create<\/span><\/i><span style=\"font-weight: 400;\"> software.<\/span><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">With Processing, an artist can invent her own tools rather than relying on those created and maintained by others. Today, being \u201csoftware literate\u201d is arguably more important than ever. Algorithms affect our lives in ways we couldn\u2019t have anticipated and the explosion of so-called \u201cdeep\u201d learning research has further extended their reach. Our interactions are now negotiated not just with each other, but with autonomous vehicles, ever-listening assistants, cameras that identify our faces and poses. Without access to and understanding of the machine learning models, underlying data, and outputs driving the software, how can we meaningfully engage, question and propose alternatives? Machine learning faces a similar challenge of approachability as simply learning to code did more than fifteen years ago. This is where <\/span><a href=\"http:\/\/ml5js.org\/\"><span style=\"font-weight: 400;\">ml5.js<\/span><\/a><span style=\"font-weight: 400;\"> comes in: a beginner-friendly library for the web to introduce coders to machine learning, from algorithms and data to models and training.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Barriers to Machine Learning While Learning<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Beginning programmers face two main barriers with <\/span><span style=\"font-weight: 400;\">current machine learning tools. Firstly, having to install and configure a development environment and secondly, having to implement low-level <\/span><span style=\"font-weight: 400;\">mathematical operations<\/span><span style=\"font-weight: 400;\">. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Take Google\u2019s TensorFlow, one of the most popular open-source library for machine learning. The installation instructions require setting up and configuring a python environment through a complex sequence of commands entered via a terminal interface as shown in the following image.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-398\" src=\"https:\/\/itp.nyu.edu\/adjacent\/issue-3\/wp-content\/uploads\/sites\/8\/2018\/06\/tensorflow_install-1024x594.png\" alt=\"A screenshot of a web browser showing the installation steps to instal the python-based library, Tensorflow.\" width=\"640\" height=\"371\" srcset=\"https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/tensorflow_install-1024x594.png 1024w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/tensorflow_install-300x174.png 300w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/tensorflow_install-768x445.png 768w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/tensorflow_install.png 1478w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">In the summer of 2017, deeplearn.js paved the way for making machine learning easier to access by bringing it to the web. Deeplearn.js was an <\/span><a href=\"https:\/\/github.com\/PAIR-code\/deeplearnjs\"><span style=\"font-weight: 400;\">open source<\/span><\/a><span style=\"font-weight: 400;\"> hardware-accelerated machine intelligence javascript library developed by <\/span><span style=\"font-weight: 400;\">Nikhil Thorat and Daniel Smilkov, researchers from Google\u2019s <\/span><a href=\"https:\/\/research.google.com\/bigpicture\/\"><span style=\"font-weight: 400;\">Big Picture Group<\/span><\/a><span style=\"font-weight: 400;\"> led by<\/span><span style=\"font-weight: 400;\"> Fernanda Vi\u00e9gas and Martin Wattenberg. Unlike the python predecessors, no environment needed to be installed and configured to use deeplearn.js. A student, artist, eductor, tinkerer, researcher could simply go to a URL and run a machine learning model in the browser. On March 30, 2018, Google announced that deeplearn.js became <\/span><a href=\"https:\/\/js.tensorflow.org\/\"><span style=\"font-weight: 400;\">TensorFlow.js<\/span><\/a><span style=\"font-weight: 400;\">, in turn expanding the capabilities, features, and development team to support the project.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Despite the ease of running a machine learning model in the browser, beginners who want to code their own still face the challenge of mathematical notation and low-level, technical code. Machine learning frameworks are commonly geared for people with advanced knowledge of calculus, linear algebra, statistics, data science, and several years of programming in a language like python or C++. While important for research and<\/span><span style=\"font-weight: 400;\"> development of new machine learning models and architectures, starting from this point can turn away newcomers with other backgrounds. Rather than thinking creatively about how to use machine learning as an artistic platform, beginners may be overwhelmed by fine distinctions between scalars, vectors, matrices, operations, inputs layers, outputs, and more. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Additionally, the TensorFlow.js examples are written using the latest features of the JavaScript language itself which might be unfamiliar to anyone in a beginner setting. Here is some example TensorFlow.js code from the \u201cGetting Started\u201d example:<\/span><\/p>\n<p>[gist https:\/\/gist.github.com\/stephkoltun\/28dbb6c05f4e92b94ad3861c6d197370]<\/p>\n<p><span style=\"font-weight: 400;\">This isn\u2019t a criticism of TensorFlow.js; the documentation and examples are excellent and thorough. It\u2019s simply for a different audience. While appropriate for an experienced data scientist with advanced JavaScript knowledge, it is not well suited for a beginning coder. In the fall of 2018 Daniel Shiffman, on behalf of ITP, received a Google Faculty Research Award to collaborate with the TensorFlow.js team and develop a higher-level library to address this gap.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">In the meantime, Cristobal Valenzuela (ITP \u201818) had already created a github repository called \u201c<\/span><a href=\"https:\/\/github.com\/cvalenzuela\/p5deeplearn\"><span style=\"font-weight: 400;\">p5deeplearn: deeplearn.js meets p5<\/span><\/a><span style=\"font-weight: 400;\">\u201d. This repository was the genesis of ml5.js, with the \u201c5\u201d paying homage to p5.js and the Processing philosophy itself. At ITP we organized a weekly working group to discuss developing the library itself and invited guest artists and researchers to participate in its development. The guests and collaborators included Jabril Ashe, Kate Compton, Hannah Davis, Darius Kazemi, Gene Kogan, Kyle McDonald, and Yining Shi.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-479\" src=\"https:\/\/itp.nyu.edu\/adjacent\/issue-3\/wp-content\/uploads\/sites\/8\/2018\/06\/composite-1024x469.jpg\" alt=\"Headshots of the different residents\" width=\"640\" height=\"293\" srcset=\"https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/composite-1024x469.jpg 1024w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/composite-300x138.jpg 300w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/composite-768x352.jpg 768w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/composite.jpg 1200w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<h2><span style=\"font-weight: 400;\">Walking Through The Machine Learning Door<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">In an introductory programming course, is it possible to include a one-week module on machine learning? What tool could be used? The TensorFlow.js team opened the door to machine learning at a single URL with the increasingly ubiquitous programming language of the web: JavaScript. With ml5.js, we invite beginners to walk through the door. Built on top of TensorFlow.js with no other external dependencies, the library provides access to machine learning algorithms and models in the browser with examples that use beginner-friendly JavaScript. By introducing beginners to machine learning, we hope to inspire creative experimentation and provoke discussions about data, training, and algorithmic bias and ethics.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">So, how does this happen? What is the first example to introduce the topic of machine learning to a beginner? Let\u2019s consider the common task of image classification. ml5.js <\/span><span style=\"font-weight: 400;\">(via TensorFlow.js) provides an interface for loading a \u201cpre-trained\u201d model from the cloud with one line of code.<\/span><\/p>\n<p>https:\/\/gist.github.com\/cvalenzuela\/09a40c72a5580ef9c5ccc59e51879f87<\/p>\n<p><span style=\"font-weight: 400;\">This model, known as \u201c<\/span><a href=\"https:\/\/arxiv.org\/abs\/1704.04861\"><span style=\"font-weight: 400;\">MobileNet<\/span><\/a><span style=\"font-weight: 400;\">\u201d was trained on <\/span><a href=\"http:\/\/www.image-net.org\/\"><span style=\"font-weight: 400;\">ImageNet<\/span><\/a><span style=\"font-weight: 400;\">, a database of approximately 15 million images labeled with 1,000 different classifications. What the model classifies a given image is entirely dependent on that training data &#8212; what is included, excluded, and how those images are labeled (or mislabeled).<\/span><\/p>\n<p><span style=\"font-weight: 400;\">As demonstrated on ml5js.org, the model and <\/span><span style=\"font-weight: 400;\">ImageClassifier<\/span><span style=\"font-weight: 400;\"> object can be used to classify an image.<\/span><\/p>\n<p><iframe loading=\"lazy\" class=\"mliframe\" src=\"https:\/\/ml5js.github.io\/ml5-homepage-demo\/\" allow=\"geolocation; microphone; camera\" width=\"100%\" height=\"520px\" frameborder=\"0\"><\/iframe><br \/>\n<span style=\"font-weight: 400;\">In addition, the classifier can label frames of recorded or live video when linked with a p5 video element.<\/span><\/p>\n<p>https:\/\/gist.github.com\/cvalenzuela\/054513b84063171b6953778a56fa2bdf<\/p>\n<p><span style=\"font-weight: 400;\">Once this happens, things get slightly more complicated as the concept of a callback must be employed when the classifier is finished analyzing the image and ready to return results.<\/span><\/p>\n<p>https:\/\/gist.github.com\/cvalenzuela\/63c20975fde4dbd7d1676f45c5ba5c42<\/p>\n<p><span style=\"font-weight: 400;\">The above code logs a list of classifications for the current video image &#8212; along with a \u201cconfidence\u201d score\u201d &#8212; to the browser console. A version of this code that displays the webcam image and results is running below (you\u2019ll have to click \u201callow webcam\u201d to see the results). <\/span><\/p>\n<p><span style=\"font-weight: 400;\">What does the model think you are? An oxygen mask? A bow-tie? A bassoon? Sunglasses?<\/span><\/p>\n<p><iframe loading=\"lazy\" class=\"mliframe\" src=\"https:\/\/ml5js.github.io\/ml5-adjacent\/02_ImageClassification_Video\/\" allow=\"geolocation; microphone; camera\" width=\"100%\" height=\"420px\" frameborder=\"0\"><\/iframe><\/p>\n<p><span style=\"font-weight: 400;\">The failure of the model to recognize a person is considered a success for ml5.js. It sparks the discussion. Why is not it not able to label me as a &#8220;person&#8221;?<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Try holding up an object in front of the camera, like your cellphone or a coffee mug.\u00a0<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-524 size-full\" src=\"https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/Screen-Shot-2018-06-15-at-9.55.45-AM.png\" alt=\"A man drinking from a coffee mug\" width=\"506\" height=\"442\" srcset=\"https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/Screen-Shot-2018-06-15-at-9.55.45-AM.png 760w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/Screen-Shot-2018-06-15-at-9.55.45-AM-300x262.png 300w\" sizes=\"(max-width: 506px) 100vw, 506px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Suddenly it works perfectly. Machine learning is not magic. The model only knows about what it\u2019s been trained with. In this case, the <\/span><i><span style=\"font-weight: 400;\">MobileNet<\/span><\/i><span style=\"font-weight: 400;\"> model was trained on a somewhat arbitrary set of objects. It\u2019s surprisingly good at recognizing obscure dog breeds and bird species, yet has no understanding of a \u201cface\u201d or \u201cperson.\u201d<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-475\" src=\"https:\/\/itp.nyu.edu\/adjacent\/issue-3\/wp-content\/uploads\/sites\/8\/2018\/06\/predictions-1024x815.jpg\" alt=\"Screenshots of classifications\" width=\"640\" height=\"509\" srcset=\"https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/predictions-1024x815.jpg 1024w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/predictions-300x239.jpg 300w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/predictions-768x611.jpg 768w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/predictions-1536x1222.jpg 1536w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/predictions-2048x1629.jpg 2048w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">It\u2019s our hope that by exposing a model\u2019s flaws and having it easily accessible in ml5.js, creative coders around the world will be inspired to make their own creative experiments while simultaneously recognizing the strengths and weaknesses of any model.<\/span><span style=\"font-weight: 400;\"> Pre-trained models like <\/span><i><span style=\"font-weight: 400;\">MobileNet<\/span><\/i><span style=\"font-weight: 400;\"> provide friendly starting points for beginners. With just a line or two of code, a variety of models can be run. Below are a few interactive demonstrations of other models available with ml5.js.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><strong>LSTM Text Generation<\/strong>: This example generates text in the style of an author via a pre-trained model ported to ml5.js by Cris Valenzuela. The model here is trained on <\/span><a href=\"http:\/\/www.gutenberg.org\/ebooks\/author\/6368\"><span style=\"font-weight: 400;\">public domain works<\/span><\/a><span style=\"font-weight: 400;\"> by <\/span><a href=\"https:\/\/en.wikipedia.org\/wiki\/Zora_Neale_Hurston\"><span style=\"font-weight: 400;\">Zora Neale Hurston<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><br \/>\n<iframe loading=\"lazy\" class=\"mliframe\" src=\"https:\/\/ml5js.github.io\/ml5-adjacent\/03_LSTM_Text\/\" allow=\"geolocation; microphone; camera\" width=\"100%\" height=\"430px\" frameborder=\"0\"><\/iframe><\/p>\n<p><span style=\"font-weight: 400;\"><strong>Style Transfer<\/strong>: This examples takes the style of one image and applies it to the content of another. The model was ported to ml5.js by ITP alumna and guest artist Yining Shi and requires a pre-trained model for a particular style. Here the model was trained on <\/span><a href=\"https:\/\/en.wikipedia.org\/wiki\/The_Great_Wave_off_Kanagawa\"><span style=\"font-weight: 400;\">The Great Wave off Kanagawa, 1829 &#8211; Katsushika Hokusai<\/span><\/a><span style=\"font-weight: 400;\">. <\/span><br \/>\n<iframe loading=\"lazy\" class=\"mliframe\" src=\"https:\/\/ml5js.github.io\/ml5-adjacent\/04_StyleTransfer_Image\/\" allow=\"geolocation; microphone; camera\" width=\"100%\" height=\"620px\" frameborder=\"0\"><\/iframe><\/p>\n<p><span style=\"font-weight: 400;\"><strong>Pitch Detection<\/strong>: This example uses a pre-trained model known as \u201cCREPE\u201d, ported to ml5.js by Hannah Davis, and was trained on several existing audio datasets <\/span><a href=\"https:\/\/arxiv.org\/abs\/1802.06182\"><span style=\"font-weight: 400;\">described in this paper<\/span><\/a><span style=\"font-weight: 400;\">. <\/span><br \/>\n<iframe loading=\"lazy\" class=\"mliframe\" src=\"https:\/\/ml5js.github.io\/ml5-adjacent\/05_Pitch\/\" allow=\"geolocation; microphone; camera\" width=\"100%\" height=\"300px\" frameborder=\"0\"><\/iframe><\/p>\n<p><span style=\"font-weight: 400;\"><strong>Word2Vec<\/strong>: Word2Vec is a model that associates a given word with a list of numbers. This allows mathematical operations to be performed on text. The numbers are generated by looking at how the words appear in relationship to other words in a corpus of text. The word vectors below are from a <\/span><a href=\"https:\/\/code.google.com\/archive\/p\/word2vec\/\"><span style=\"font-weight: 400;\">Google open source model trained on news articles<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><br \/>\n<iframe loading=\"lazy\" class=\"mliframe\" src=\"https:\/\/ml5js.github.io\/ml5-adjacent\/06_Word2Vec\/\" allow=\"geolocation; microphone; camera\" width=\"100%\" height=\"180px\" frameborder=\"0\"><\/iframe><\/p>\n<p><span style=\"font-weight: 400;\"><strong>PoseNet<\/strong>: PoseNet, ported to ml5.js by current ITP student Dan Oved, is a model that performs \u201cpose estimation\u201d, a computer vision technique to determine the pixel location of key points on a human body in an image. The pre-trained model was created using t<\/span><span style=\"font-weight: 400;\">he <\/span><a href=\"http:\/\/mi.eng.cam.ac.uk\/projects\/relocalisation\/\"><span style=\"font-weight: 400;\">Cambridge Landmarks<\/span><\/a><span style=\"font-weight: 400;\"> and <\/span><a href=\"https:\/\/www.microsoft.com\/en-us\/research\/project\/rgb-d-dataset-7-scenes\/\"><span style=\"font-weight: 400;\">7-Scenes Dataset<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><br \/>\n<iframe loading=\"lazy\" class=\"mliframe\" src=\"https:\/\/ml5js.github.io\/ml5-adjacent\/07_PoseNet\/\" allow=\"geolocation; microphone; camera\" width=\"100%\" height=\"360px\" frameborder=\"0\"><\/iframe><\/p>\n<p><span style=\"font-weight: 400;\">In documenting the above examples, our priority is to be clear and transparent with where the model is sourced from, what data was used to train the model, and what data might be missing.<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">Creative Datasets and Responsible Data Practices<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">The preceding examples highlight the core features and goals of ml5.js version 0.1.0, the very first beta. But there\u2019s much more to come. Beyond an educational and creative resource for experimenting with pre-trained models, the library also aims to introduce students and creative coders to the entire machine learning process: from collecting data, cleaning data, training a model, testing a model, and deploying. How can we make this full narrative available and accessible to beginners?<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Two aspects of the project hint at what is to come: easily accessible sample datasets within the library plus functions to help segment data and process batches to train a model. This work has largely been driven by Hannah Davis (ITP \u201813) who spent the semester in residence working on ml5.js and related machine learning research focused on datasets. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">It\u2019s easy to forget all the work that goes into processing data before actually using the data itself. When first introducing machine learning, sample datasets can act as a starting point for beginners to explore key concepts. At our first ml5 meetup, Hannah presented the <\/span><a href=\"http:\/\/scikit-learn.org\/stable\/datasets\/index.html\"><span style=\"font-weight: 400;\">toy datasets<\/span><\/a><span style=\"font-weight: 400;\"> included in scikit-learn, a machine learning library for Python.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-412\" src=\"https:\/\/itp.nyu.edu\/adjacent\/issue-3\/wp-content\/uploads\/sites\/8\/2018\/06\/Screenshot-2018-06-14-17.39.51-1024x372.png\" alt=\"A list of small datasets provided by scikit-learn\" width=\"640\" height=\"233\" srcset=\"https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/Screenshot-2018-06-14-17.39.51-1024x372.png 1024w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/Screenshot-2018-06-14-17.39.51-300x109.png 300w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/Screenshot-2018-06-14-17.39.51-768x279.png 768w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/Screenshot-2018-06-14-17.39.51-1536x558.png 1536w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/Screenshot-2018-06-14-17.39.51.png 1612w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Hannah asked: what if ml5.js also included sample datasets that people could access with a call to a JavaScript function? In addition, clear documentation &#8212; further inspired by \u00a0scikit-learn\u2019s \u201cdescribe\u201d function &#8212; could describe the dataset including its origins, how it was collected, and what it contains. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Literacy around datasets also includes how it is used within models. Distinctions within datasets such as training, testing, validation and unknown data can be particularly confusing for beginners to machine learning. Incorporating features of the library to help segment data and process it in different batches would introduce people to the process. While this is not part of the first release for ml5.js, it is something we hope to incorporate next.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Lastly, what data we choose to provide is just as important as how we provide it. A core principle of ml5 is to feature non-traditional kinds of data. The classic <\/span><a href=\"https:\/\/archive.ics.uci.edu\/ml\/datasets\/iris\"><span style=\"font-weight: 400;\">IRIS flower data set<\/span><\/a><span style=\"font-weight: 400;\"> for classification has found its place in countless data science examples and the even more ubiquitous <\/span><a href=\"http:\/\/yann.lecun.com\/exdb\/mnist\/\"><span style=\"font-weight: 400;\">MNIST database of labeled handwritten digits<\/span><\/a><span style=\"font-weight: 400;\"> is found in almost every introductory machine learning image classification tutorial. Non-traditional datasets can encourage people to think creatively about data and how they might use their own data in a project. One way to do this is to pick sample datasets from creative art spaces. The database of \u201cdoodles\u201d from Google\u2019s quickdraw dataset can act as a fun, playful variation on MNIST. <\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-413\" src=\"https:\/\/itp.nyu.edu\/adjacent\/issue-3\/wp-content\/uploads\/sites\/8\/2018\/06\/quickdraw_data-1024x594.png\" alt=\"lots of hand draw objects\" width=\"640\" height=\"371\" srcset=\"https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/quickdraw_data-1024x594.png 1024w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/quickdraw_data-300x174.png 300w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/quickdraw_data-768x445.png 768w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/quickdraw_data.png 1478w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Hannah\u2019s <\/span><a href=\"https:\/\/github.com\/ml5js\/ml5-data-and-training\/tree\/master\/datasets\/landscapes\"><span style=\"font-weight: 400;\">first sample dataset<\/span><\/a><span style=\"font-weight: 400;\"> contributed to the library is a set of just under 4,000 landscape images. Like one might expect, the landscapes are labeled in a traditional way with seven categories: \u201cfield, mountain, city, lake, forest, ocean, road.\u201d However, Hannah also conducted an experiment by using a crowdsourcing website to have people label the images with a more subjective \u201cemotional\u201d quality, with the eventual goal being to train a model to detect emotion in images. In <\/span><a href=\"https:\/\/itp.nyu.edu\/AI\/creating-datasets\/\"><span style=\"font-weight: 400;\">her blog post about the dataset<\/span><\/a><span style=\"font-weight: 400;\">, Hannah writes:<\/span><\/p>\n<blockquote><p><i><span style=\"font-weight: 400;\">This second usage is an experiment on my part to explore something I\u2019ve been calling \u2018subjective datasets,\u2019 or datasets where the labels are wildly more subjective than something like \u2018cat\u2019 or \u2018dog.\u2019 This overlaps quite a bit with sentiment analysis, and is my first attempt at creating an emotional dataset. <\/span><\/i><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">In addition to the dataset and walkthrough of how it was created, Hannah published a \u201c<\/span><a href=\"https:\/\/ml5js.org\/docs\/data-preparing-your-own-data\"><span style=\"font-weight: 400;\">Making Your Own Datasets<\/span><\/a><span style=\"font-weight: 400;\">\u201d tutorial for the ml5 website, answering questions such as \u201cWhere does data come from?\u201d and \u201cWhere do labels come from?\u201d as well as emphasizing \u201cResponsible Data Collection\u201d. <\/span><\/p>\n<blockquote><p><i><span style=\"font-weight: 400;\">It is important, when collecting data, to think critically at every stage along the collection process. Some questions to ask yourself include: Whose data is this? Would they want you to scrape this? Is it public? Is there a way to ask permission and\/or pay for the data? Can you collect data with appropriate licensing?<\/span><\/i><\/p>\n<p><i><span style=\"font-weight: 400;\">You want to be careful of under-representation bias in data collection (also known as sampling bias. For example, if you&#8217;re collecting a dataset of the best movies of all time, are you asking only those in your immediate circle? For situations where there are obvious gaps in your data, it&#8217;s important to see if there&#8217;s a way to collect more, from varied sources.<\/span><\/i><\/p>\n<p><i><span style=\"font-weight: 400;\">The converse of this is collecting too much data. Is it really necessary to your project to ask for gender and age? Could collecting religion, ethnicity, or nationality be dangerous now or down the road? Are you collecting only what is absolutely necessary? Is there something that would be better to leave out?<\/span><\/i><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">Hannah\u2019s work inspired us to think about what is missing from the pre-trained models we provide. For beginners who feel intimidated by machine learning or that they do not belong, it\u2019s important for everyone to see themselves in the data. During our first round of ml5.js development, we trained the text generator example described above with three authors: Shakespeare, Hemingway, and Nietzsche. These authors all have something in common: they are deceased white men. Recognizing this, we searched through <\/span><a href=\"http:\/\/www.gutenberg.org\/\"><span style=\"font-weight: 400;\">Project Gutenberg<\/span><\/a><span style=\"font-weight: 400;\">, a database of public domain texts, and pulled a more inclusive selection of authors that includes women and people of color. Our pre-trained model list is now: Roberto Bola\u00f1o, Charles Darwin, W. E. B. Du Bois, Ernest Hemingway, William Shakespeare, Mary Shelley, Zora Neale Hurston, and Virginia Woolf.<\/span><\/p>\n<h2>Building on Pre-Trained Models<\/h2>\n<p><span style=\"font-weight: 400;\">Another effective technique for working with custom datasets is referred to as \u201ctransfer learning.\u201d In this case, instead of training a machine learning model from scratch with a dataset, a pre-trained model is used as the starting point for training with new data. Working with the TensorFlow.js team, researchers and artists from Google Creative Lab developed a project called \u201c<\/span><a href=\"https:\/\/g.co\/teachablemachine\"><span style=\"font-weight: 400;\">Teachable Machines<\/span><\/a><span style=\"font-weight: 400;\">\u201d that demonstrates this process. With a webcam, someone can interactively and in real-time train a machine learning model to classify input from a video camera. \u00a0<\/span><\/p>\n<div id=\"attachment_414\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-414\" class=\"size-large wp-image-414\" src=\"https:\/\/itp.nyu.edu\/adjacent\/issue-3\/wp-content\/uploads\/sites\/8\/2018\/06\/teachable_machine-1024x707.jpg\" alt=\"Nicole He from Google Creative Lab demonstrates Teachable Machine: an experiment that makes it easier for anyone to explore machine learning, live in the browser \u2013 no coding required. \" width=\"640\" height=\"442\" \/><p id=\"caption-attachment-414\" class=\"wp-caption-text\">Nicole He from Google Creative Lab demonstrates Teachable Machine: an experiment that makes it easier for anyone to explore machine learning, live in the browser \u2013 no coding required.<\/p><\/div>\n<p><span style=\"font-weight: 400;\">In addition to the Teachable Machine website itself, Google released \u201c<\/span><a href=\"https:\/\/github.com\/googlecreativelab\/teachable-machine-boilerplate\"><span style=\"font-weight: 400;\">teachable machine boilerplate<\/span><\/a><span style=\"font-weight: 400;\">\u201d: the bare minimum amount of JavaScript code needed to create your own version. This inspired us to think about an ml5.js version of transfer learning. How do we make the process simple but expose its details to reduce the feeling of \u201cmagic\u201d? For this end, we incorporated a \u201cFeatureExtractor.\u201d<\/span><\/p>\n<p>https:\/\/gist.github.com\/cvalenzuela\/bb5c54e9d640952f65a22dea64106c9a<\/p>\n<p><span style=\"font-weight: 400;\">As discussed earlier, <\/span><i><span style=\"font-weight: 400;\">MobileNet<\/span><\/i><span style=\"font-weight: 400;\"> was designed to assign a label to an image: \u201ccoffee mug\u201d, \u201cturtle\u201d, etc. However, behind the scenes, before it actually does so, the <\/span><i><span style=\"font-weight: 400;\">MobileNet<\/span><\/i><span style=\"font-weight: 400;\"> model runs a mathematical process called a \u201cconvolution\u201d (similar to what happens in a photoshop filter) which transforms all the pixels into a reduced set of numbers. A 200&#215;200 image with 40,000 pixels results in a list of 135 floating point numbers. These numbers are considered the \u201cfeatures\u201d of the image. While <\/span><i><span style=\"font-weight: 400;\">MobileNet<\/span><\/i><span style=\"font-weight: 400;\"> might associate of a certain set of features with a \u201ccoffee mug\u201d the transfer learning process allows us to assign new labels to the features extracted from new images.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Once we have the extractor, the next step is to create a classifier from it:<\/span><\/p>\n<p>https:\/\/gist.github.com\/cvalenzuela\/012a8016e723a3d66fd6b977c4eb3256<\/p>\n<p><span style=\"font-weight: 400;\">We can tell the classifier about images that with our own labels.<\/span><\/p>\n<p>https:\/\/gist.github.com\/cvalenzuela\/8fe7ccf3094f051608e745aaff187276<\/p>\n<p><span style=\"font-weight: 400;\">Finally we can train a new model based on the features on the images we added.<\/span><\/p>\n<p>https:\/\/gist.github.com\/cvalenzuela\/4c129650f58803f210b405afff0e1192<\/p>\n<p><span style=\"font-weight: 400;\">And classify a new unknown image.<\/span><\/p>\n<p>https:\/\/gist.github.com\/cvalenzuela\/363c5d5a368aacbff0e092d816c64244<\/p>\n<p><span style=\"font-weight: 400;\">A use case of this is to train an interactive system to recognize custom images. Alejandro Matamala created one of the first projects at ITP with this approach in \u201cPongML\u201d. In his project, someone <\/span><span style=\"font-weight: 400;\">trains a machine learning model in realtime to recognize and then play the game according to person\u2019s specific poses.<\/span><\/p>\n<p><a href=\"https:\/\/github.com\/matamalaortiz\/Pong-ML\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-415\" src=\"https:\/\/itp.nyu.edu\/adjacent\/issue-3\/wp-content\/uploads\/sites\/8\/2018\/06\/pongml-1024x576.jpg\" alt=\"Playing pong with a webcam\" width=\"640\" height=\"360\" srcset=\"https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/pongml-1024x576.jpg 1024w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/pongml-300x169.jpg 300w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/pongml-768x432.jpg 768w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/pongml.jpg 1280w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<h2><span style=\"font-weight: 400;\">What\u2019s next?<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">The first commit to the ml5 library itself was on Oct 4, 2017. A little over eight months later, thanks to the support from Google, we are thrilled to release this first \u201cbeta\u201d (version 0.1.0) of ml5.js. <\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-416\" src=\"https:\/\/itp.nyu.edu\/adjacent\/issue-3\/wp-content\/uploads\/sites\/8\/2018\/06\/eyebeam-1024x683.jpg\" alt=\"A group of people watching a presentation on a screen.\" width=\"640\" height=\"427\" srcset=\"https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/eyebeam-1024x683.jpg 1024w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/eyebeam-300x200.jpg 300w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/eyebeam-768x512.jpg 768w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/eyebeam.jpg 1200w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">While there have been a few workshops taught with ml5 at <\/span><a href=\"http:\/\/itp.nyu.edu\/\"><span style=\"font-weight: 400;\">ITP<\/span><\/a><span style=\"font-weight: 400;\">, <\/span><a href=\"http:\/\/sfpc.io\/\"><span style=\"font-weight: 400;\">The School for Poetic Computation<\/span><\/a><span style=\"font-weight: 400;\">, and <\/span><a href=\"https:\/\/www.eyebeam.org\/\"><span style=\"font-weight: 400;\">Eyebeam<\/span><\/a><span style=\"font-weight: 400;\"> already, the real work begins now as artists, educators, and beginning coders use the library in education and practice. What is not clear? What is missing from the documentation? Where do things seem too much like magic? Too complicated? The best way to develop a library for beginners is to work with the library with beginners.\u00a0<\/span><\/p>\n<p><a href=\"https:\/\/yining1023.github.io\/pix2pix_tensorflowjs\/\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-568 size-large\" src=\"https:\/\/itp.nyu.edu\/adjacent\/issue-3\/wp-content\/uploads\/sites\/8\/2018\/06\/Screen-Shot-2018-06-17-at-4.20.20-PM-1024x597.png\" alt=\"Sketch of Pikachu\" width=\"1024\" height=\"597\" srcset=\"https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/Screen-Shot-2018-06-17-at-4.20.20-PM-1024x597.png 1024w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/Screen-Shot-2018-06-17-at-4.20.20-PM-300x175.png 300w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/Screen-Shot-2018-06-17-at-4.20.20-PM-768x448.png 768w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/Screen-Shot-2018-06-17-at-4.20.20-PM.png 1390w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">We hope this release is just the beginning; more tutorials, examples, and models are coming over the summer. One that we are particularly excited about for its creative possibilities is image to image translation (known as pix2pix) that Yining Shi is <a href=\"https:\/\/yining1023.github.io\/pix2pix_tensorflowjs\/\">in the process of porting<\/a> to ml5.js. Yining will also be teaching the first workshop with ml5.js beta at ITP camp! In the fall, Gene Kogan and Mimi Onuoha will be in residence at ITP to continue to help us think through the API choices and ethical questions surrounding the development of the library and associated datasets and documentation.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-484\" src=\"https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/composite-2.jpg\" alt=\"Two headshots of future residents\" width=\"529\" height=\"253\" srcset=\"https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/composite-2.jpg 529w, https:\/\/itp.nyu.edu\/adjacent\/wp-content\/uploads\/2018\/06\/composite-2-300x143.jpg 300w\" sizes=\"(max-width: 529px) 100vw, 529px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">And yes, that ITP course \u201cIntroduction to Computational Media\u201d for beginners learning to code for the very first time will include a new one week module in the fall semester: <\/span><i><span style=\"font-weight: 400;\">machine learning<\/span><\/i><span style=\"font-weight: 400;\">. Join our\u00a0<a href=\"http:\/\/ml5js.slack.com\">Slack channel<\/a>, follow us on <a href=\"https:\/\/twitter.com\/ml5js?lang=en\">Twitter<\/a>, and contribute to the <a href=\"https:\/\/github.com\/ml5js\">Github repository<\/a>\u00a0to participate in the discussion!<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How can we build a machine learning library that&#8217;s approachable for people beginning to code?<\/p>\n","protected":false},"author":23,"featured_media":416,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-312","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-issue-3"],"_links":{"self":[{"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/posts\/312"}],"collection":[{"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/users\/23"}],"replies":[{"embeddable":true,"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/comments?post=312"}],"version-history":[{"count":1,"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/posts\/312\/revisions"}],"predecessor-version":[{"id":2667,"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/posts\/312\/revisions\/2667"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/media\/416"}],"wp:attachment":[{"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/media?parent=312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/categories?post=312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itp.nyu.edu\/adjacent\/wp-json\/wp\/v2\/tags?post=312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}