<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Haripriya2002145</title>
    <description>The latest articles on DEV Community by Haripriya2002145 (@haripriya2002145).</description>
    <link>https://dev.to/haripriya2002145</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F650658%2F72f4503d-0f44-4bf9-beec-dc262e7a7d51.jpg</url>
      <title>DEV Community: Haripriya2002145</title>
      <link>https://dev.to/haripriya2002145</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/haripriya2002145"/>
    <language>en</language>
    <item>
      <title>Learning the elements of the Modern Periodic Table through a web application using SashiDo and Teachable Machine</title>
      <dc:creator>Haripriya2002145</dc:creator>
      <pubDate>Sun, 20 Nov 2022 19:38:57 +0000</pubDate>
      <link>https://dev.to/haripriya2002145/learning-the-elements-of-the-modern-periodic-table-through-a-web-application-using-sashido-and-teachable-machine-a8b</link>
      <guid>https://dev.to/haripriya2002145/learning-the-elements-of-the-modern-periodic-table-through-a-web-application-using-sashido-and-teachable-machine-a8b</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhfo1tt59bipso3vvae12.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhfo1tt59bipso3vvae12.png" alt="QuantumX"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hi there! I am delighted to talk about a web application called QuantumX, which I created for an internship at &lt;a href="https://www.sashido.io/en/" rel="noopener noreferrer"&gt;SashiDo&lt;/a&gt;. Basically, the application helps you in learning the first 30 elements of &lt;a href="https://byjus.com/periodic-table/" rel="noopener noreferrer"&gt;Modern Periodic Table&lt;/a&gt;, in the order of increasing &lt;a href="https://www.angelo.edu/faculty/kboudrea/periodic/structure_numbers.htm" rel="noopener noreferrer"&gt;atomic number&lt;/a&gt;, along with it's properties such as atomic masses, group numbers and electronic configurations. The periodic table of elements is widely used in the field of Chemistry to look up chemical elements as they are arranged in a manner that displays periodic trends and correlations in the chemical properties of the elements. Moreover, every science student must be aware of the properties of first 30 elements at the least to crack any entrance exam. "QuantumX" will be helpful to learn and memorize the elements as it pictorially represents the element's symbol and properties. I used &lt;a href="https://teachablemachine.withgoogle.com/train/image" rel="noopener noreferrer"&gt;Teachable Machine&lt;/a&gt; to detect the element from an image model. Essentially, when you show a picture of element's symbol, the full name of the element is detected. &lt;/p&gt;

&lt;p&gt;Before we could see how to create this simple application, make sure to create an account on &lt;a href="https://dashboard.sashido.io/register" rel="noopener noreferrer"&gt;SashiDo&lt;/a&gt;. It is a company that provides very pleasing and lovely backend service platform. Once your account is created, you will be given sufficient time to prepare and create your project.&lt;/p&gt;

&lt;h1&gt;
  
  
  Table of contents
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;About the project&lt;/li&gt;
&lt;li&gt;
Teachable Machine

&lt;ul&gt;
&lt;li&gt;Be ready with your data set&lt;/li&gt;
&lt;li&gt;Create and train your model&lt;/li&gt;
&lt;li&gt;Export the model&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Create a responsive website&lt;/li&gt;

&lt;li&gt;Connecting the App with SashiDo by Parse&lt;/li&gt;

&lt;li&gt;User Registration (Login and Sign in)&lt;/li&gt;

&lt;li&gt;

How to use Teachable Machine Image Model in the website

&lt;ul&gt;
&lt;li&gt;Provide input through webcam&lt;/li&gt;
&lt;li&gt;Provide input by uploading images&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Showing and hiding the properties of elements&lt;/li&gt;

&lt;li&gt;Video of the working of QuantumX&lt;/li&gt;

&lt;li&gt;Closing Remarks&lt;/li&gt;

&lt;li&gt;Useful links&lt;/li&gt;

&lt;/ul&gt;

&lt;h1&gt;
  
  
  About the project
&lt;/h1&gt;

&lt;p&gt;The name "QuantumX" derives from the word &lt;strong&gt;Quantum&lt;/strong&gt;, which is the smallest unit of energy or matter, and &lt;strong&gt;X&lt;/strong&gt; denotes the chemical symbol of the elements.&lt;/p&gt;

&lt;p&gt;I have used &lt;strong&gt;HTML5, CSS and JavaScript&lt;/strong&gt; to create a &lt;strong&gt;responsive website&lt;/strong&gt; wherein an image model(ML model) is used to detect elements. That is, the ML model uses Teachable Machine to get the input element's symbol either through webcam or image file uploaded, and provides the details of that element.&lt;/p&gt;

&lt;p&gt;The video demo:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F10e01f26jy54m4egb16z.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F10e01f26jy54m4egb16z.gif" alt="Webcam runthrough"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Teachable Machine
&lt;/h1&gt;

&lt;p&gt;This is one of the interesting parts which makes sense to your whole idea in creating this web application. "Teachable Machine" may sound a bit new to you, but once you work with it, you will start playing with it. &lt;a href="https://teachablemachine.withgoogle.com/train" rel="noopener noreferrer"&gt;Teachable Machine&lt;/a&gt; is a web-based tool that helps in creating your ML models yourself even if you are just a beginner. All it requires is the data set that you provide to train your model to recognize variety of information.&lt;/p&gt;

&lt;p&gt;To create your own exciting ML model, follow these simple steps:&lt;/p&gt;

&lt;h2&gt;
  
  
  Be ready with your data set
&lt;/h2&gt;

&lt;p&gt;Gather and categorize the input files in a location. The more pictures you provide your model the more it's precision in detecting an image will be.&lt;br&gt;
In my case, the data set for uploading files will be looking like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fznjwl49erm80lik4hifg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fznjwl49erm80lik4hifg.jpg" alt="Elements"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Create and train your model
&lt;/h2&gt;

&lt;p&gt;Click on this &lt;a href="https://teachablemachine.withgoogle.com/train/image" rel="noopener noreferrer"&gt;link&lt;/a&gt;. Name the classes with full name of the symbol such as . Take four elements at a time, in the order of increasing atomic number, so it would be easier for learners to study about them. Taking all thirty elements at once will also delay the training process. &lt;/p&gt;

&lt;p&gt;Provide both webcam images and image files to your model. For webcam inputs, use white cards and letters from print outs. Check how I have used these in "this" section. You can also try other means of exhibiting these symbols as you please.&lt;/p&gt;

&lt;p&gt;Click on &lt;strong&gt;Train Model&lt;/strong&gt; to train your model. Don't switch tabs at this time. &lt;/p&gt;
&lt;h2&gt;
  
  
  Export the model
&lt;/h2&gt;

&lt;p&gt;Once your model is trained, play with it by testing different elements and it's confidence in answers. &lt;/p&gt;

&lt;p&gt;Now, it's time to export your model. Click on &lt;strong&gt;Export Model&lt;/strong&gt; and click on &lt;strong&gt;Upload my model&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd9i7q5h905aac3i5rmw6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd9i7q5h905aac3i5rmw6.jpg" alt="Click on Upload My Model"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After this, copy the JavaScript code in Tensorflow.js and the sharable link for later use:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0uy5xfg4n9fjuktyesqo.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0uy5xfg4n9fjuktyesqo.jpg" alt="Copy the link and code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Make sure that you save all the image model sharable links in a notepad for later use. We will be seeing how to use these links in "this" section.&lt;/p&gt;
&lt;h1&gt;
  
  
  Create a responsive website
&lt;/h1&gt;

&lt;p&gt;For a good user interface, I suggest you to design and structure your website in &lt;a href="https://www.figma.com/" rel="noopener noreferrer"&gt;Figma&lt;/a&gt;. It is an awesome prototyping tool which is completely free to use. Also, you can get the code in CSS, iOS and Android for each component of the design. When you get ready with UI of your website, start creating the website in Visual Studios. If you haven't downloaded yet, &lt;a href="https://visualstudio.microsoft.com/" rel="noopener noreferrer"&gt;click here&lt;/a&gt; to download the latest version. Click on the "Community Version" as shown below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwy7zdhbfqoh7ub48irfh.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwy7zdhbfqoh7ub48irfh.jpg" alt="Microsoft Visual Studio"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use Visual Studios to create the entire application, as it supports all functions needed to execute Teachable Machine and Parse. Create a folder to save all files in HTML5, CSS and JavaScript. Maintain a separate file for images and icons.&lt;/p&gt;

&lt;p&gt;Do watch the tutorial videos in YouTube for creating a website. However, If you are just a beginner and you want know how to build a website from the basic, &lt;a href="https://www.w3schools.com/howto/howto_website_create_free.asp" rel="noopener noreferrer"&gt;click on this tutorial&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;To make your website respond to the user's behavior and environment based on screen size, platform and orientation, it is a good practice to create a &lt;a href="https://www.w3schools.com/html/html_responsive.asp" rel="noopener noreferrer"&gt;Responsive Website&lt;/a&gt;. Make sure that you use &lt;a href="https://www.w3schools.com/css/css3_flexbox.asp" rel="noopener noreferrer"&gt;CSS flexbox&lt;/a&gt; in all web pages.&lt;/p&gt;

&lt;p&gt;Add the following  tag to all your web pages, to create a responsive website:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In CSS design, use the following code to change designs of different screen lengths:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media only screen and (max-width: 700px)
{
  /*code*/
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In my case, I have used "max-width: 700px". Try giving different values for "max-width" that is compatible with your web page. To know more about this CSS syntax check out the &lt;a href="https://www.w3schools.com/cssref/css3_pr_mediaquery.asp" rel="noopener noreferrer"&gt;CSS @media rule&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Connecting the App with SashiDo by Parse
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;After creating the account on SashiDo, go to the dashboard, Click on &lt;strong&gt;Create New App&lt;/strong&gt; and &lt;a href="https://blog.sashido.io/sashidos-getting-started-guide/#howtocreateanappwithsashidofromscratch" rel="noopener noreferrer"&gt;follow these instructions&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;In the "Getting Started" page in SashiDo , copy the code in JavaScript and paste it in the "app.js" file. This code will connect your application with SashiDo.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsuydnrcduntnf773qmcu.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsuydnrcduntnf773qmcu.jpg" alt="Connect with SashiDo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will use the same "app.js" file to function registration pages using Parse, in the next section.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add this Parse script at the bottom of your "index.html" file, which will contain &lt;code&gt;&amp;lt;script src="app.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script src="https://cdnjs.cloudflare.com/ajax/libs/parse/3.1.0/parse.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  User Registration
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Create a form in "index.html" page that has options to "Log In" and "Sign Up":
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div id="form-container"&amp;gt;
    &amp;lt;form id="form"&amp;gt;
        &amp;lt;div&amp;gt;
            &amp;lt;div class="name1"&amp;gt;&amp;lt;input type="text" id="username" placeholder="Username" name="username"&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div class="name2"&amp;gt;&amp;lt;input type="password" id="pass" placeholder="Password" name="pass"&amp;gt;&amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/form&amp;gt;
    &amp;lt;div&amp;gt;
        &amp;lt;div id="buttonsContainer"&amp;gt;
            &amp;lt;div class="click1"&amp;gt;&amp;lt;button type="button" id="login"&amp;gt;Log In&amp;lt;/button&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div class="click2"&amp;gt;&amp;lt;button type="button" id="sign"&amp;gt;Sign Up&amp;lt;/button&amp;gt;&amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;span id="returnMessage"&amp;gt;&amp;lt;/span&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure that you have added the Parse script that implements all functions in Parse.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create functions to invoke Log In and Sign Up requests in Parse. I recommend you to see &lt;a href="https://docs.parseplatform.org/js/guide/" rel="noopener noreferrer"&gt;Parse JavaScript Guide&lt;/a&gt; to understand how to use Parse for user registration.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Registration Pages
async function logIn() {
    const username = document.getElementById("username").value;
    const pass = document.getElementById("pass").value;
    const formContainer = document.getElementById("form-container");
    const container = document.getElementById("container");
    let span = document.getElementById("returnMessage");

    const onFulfilled = () =&amp;gt; {
        span.textContent = "Successful Log In!";
        window.open("website.html", "_self");
    };

    const onRejected = () =&amp;gt; {
        span.textContent = "Incorrect username or password";
    };

    const user = await Parse.User.logIn(username, pass).then(
      onFulfilled,
      onRejected
    );
}
async function signUp() {
    const username = document.getElementById("username").value;
    const pass = document.getElementById("pass").value;
    let span = document.getElementById("returnMessage");
    const user = new Parse.User();
    user.set("username", username);
    user.set("password", pass);


    try {
        await user.signUp();
        span.textContent = "Successfully signed Up";
        window.open("website.html", "_self");
    } catch (error) {
        span.textContent = "Error: " + error.code + " " + error.message;
    }
}

// Add on click listener to call the create parse user function
document.getElementById("sign").addEventListener("click", async function () {
    signUp();
});

// Add on click listener to call the create parse user function
document.getElementById("login").addEventListener("click", async function () {
    logIn();
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;When you execute the Parse code to connect SashiDo, you can see the updates in the "session" section in the Database Browser. Similarly, when you perform "Log In" and "Sign Up" operations, you can view the updated user accounts in the Browser:
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdx9g5pvgmjukeuybyma6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdx9g5pvgmjukeuybyma6.jpg" alt="Users"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  How to use Teachable Machine Image Model in the website
&lt;/h1&gt;

&lt;p&gt;We need around eight ML image models to cover all thirty elements. We will use one model for 4 elements. Now, let's see the working of teachable machine functions for the first 4 elements: &lt;strong&gt;Hydrogen, Helium, Lithium and Beryllium&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzgpvem1atr3gzn1skxsf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzgpvem1atr3gzn1skxsf.jpg" alt="H to Be"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;As you can see, we need Teachable Machine functions to carry out the working of "Start Webcam" and "Upload Image". Build a HTML page for each ML model like shown here:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="container"&amp;gt;
    &amp;lt;div class="padding1"&amp;gt;
        &amp;lt;div class="headContainer"&amp;gt;&amp;lt;span class="v248_12"&amp;gt;H to Be&amp;lt;/span&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;div class="buttonAll"&amp;gt;
        &amp;lt;button type="button" onclick="startCamHandler()" id="camButton"&amp;gt;Start Webcam&amp;lt;/button&amp;gt;
        &amp;lt;button type="button" onclick="startUpHandler()" id="upButton"&amp;gt;Upload Image&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;


    &amp;lt;div id="game-container"&amp;gt;
        &amp;lt;div id="webcam-container" class="d-none"&amp;gt;&amp;lt;/div&amp;gt;

        &amp;lt;input type="file" id="inp" class="d-none"&amp;gt;
        &amp;lt;canvas id="canvas" class="d-none"&amp;gt;&amp;lt;/canvas&amp;gt;

        &amp;lt;div id="label-container" class="d-none"&amp;gt;&amp;lt;/div&amp;gt;
        &amp;lt;div id="fullAnswer" class="d-none"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;form method="get" action="website.html"&amp;gt;
        &amp;lt;button class="back" type="submit"&amp;gt;Back&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;It is very important to add these script tags to execute the ML model:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.3.1/dist/tf.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="https://cdn.jsdelivr.net/npm/@teachablemachine/image@0.8/dist/teachablemachine-image.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="https://cdnjs.cloudflare.com/ajax/libs/parse/3.1.0/parse.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;In the JS file, add the Teachable Machine model URL in a constant :
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// H to Be elements
//Teachable Machine model Url

const URL = "https://teachablemachine.withgoogle.com/models/XTs3NXuAG/"; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now, add the following code to start and stop webcam:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let model, webcam, labelContainer, maxPredictions;
//is started Webcam flag
let startCamFlag = true;
//is started Upload flag
let startUpFlag = true;

let camButton = document.getElementById("camButton"), upButton = document.getElementById("upButton");


function startCamHandler() {
    if (startUpFlag) {
        if (startCamFlag) init();
        else stop();
        startCamFlag = !startCamFlag;
    }
}

function startUpHandler() {
    if (startCamFlag) {
        if (startUpFlag) openUploadImage();
        else closeUploadImage();
        startUpFlag = !startUpFlag;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Provide input through webcam
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In this "init()" function, check whether flip needs to be given. I did not use the flip as it will be inappropriate with letters/symbols.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Load the image model and setup the webcam
async function init() {
    const modelURL = URL + "model.json";
    const metadataURL = URL + "metadata.json";

    // load the model and metadata
    // Refer to tmImage.loadFromFiles() in the API to support files from a file picker
    // or files from your local hard drive
    // Note: the pose library adds "tmImage" object to your window (window.tmImage)
    model = await tmImage.load(modelURL, metadataURL);
    maxPredictions = model.getTotalClasses();

    // Convenience function to setup a webcam
    const flip = true; // whether to flip the webcam
    webcam = new tmImage.Webcam(200, 200); // width, height, flip
    await webcam.setup(); // request access to the webcam
    await webcam.play();
    window.requestAnimationFrame(loop);

    // append elements to the DOM
    document.getElementById("webcam-container").appendChild(webcam.canvas);
    labelContainer = document.getElementById("label-container");

    labelContainer.appendChild(document.createElement("div"));

    //Changing button text
    camButton.textContent = "Stop";

    //Showing containers 
    document.getElementById("webcam-container").className = "";
    document.getElementById("label-container").className = "";
    document.getElementById("fullAnswer").className="";

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Use the following function to stop webcam:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function stop() {
    await webcam.stop();
    document.getElementById("webcam-container").removeChild(webcam.canvas);

    labelContainer = document.getElementById("label-container");
    console.log(labelContainer.children);

    labelContainer.removeChild(labelContainer.children[0]);

    camButton.textContent = "Start Webcam";

    //Change Answer
    document.getElementById("fullAnswer").innerHTML="";

    //Hiding containers
    document.getElementById("webcam-container").className = "d-none";
    document.getElementById("label-container").className = "d-none";
    document.getElementById("fullAnswer").className="d-none";

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When "Stop webcam" is clicked, the answers will be removed from the container.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now, create the loop to update the webcam inputs, so we will get the corresponding prediction that is equivalent with the image shown in webcam.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function loop() {
    webcam.update(); // update the webcam frame
    await predict();
    window.requestAnimationFrame(loop);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now, create the function to predict the class that gets highest probability in being similar to the image shown in webcam. Then, the corresponding name, atomic number, atomic mass and electronic configuration of the class are displayed.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// run the webcam image through the image model
async function predict(imageModel = webcam.canvas) {
    let highestProbability;
    let lastProbability = 0;
    // predict can take in an image, video or canvas html element

    const prediction = await model.predict(imageModel);
    console.log(prediction);
    for (let i = 0; i &amp;lt; maxPredictions; i++) {
        if (prediction[i].probability.toFixed(2) &amp;gt; lastProbability)
            highestProbability = i;
        lastProbability = prediction[i].probability.toFixed(2);
    }
    const className1 = prediction[highestProbability].className;
    let classNameShow = className1;
    //document.getElementById("label-container").innerHTML=classNameShow;
    labelContainer.childNodes[0].innerHTML = classNameShow;

    //Predict the answer
    if(classNameShow=="Hydrogen"){
        document.getElementById("fullAnswer").innerHTML="Atomic Number: 1 &amp;lt;br&amp;gt; Atomic Mass: 1.00797 amu &amp;lt;br&amp;gt; Group: 1 &amp;lt;br&amp;gt; Electronic Configuration: 1s"+'1'.sup();
    }
    else if(classNameShow=="Helium"){
        document.getElementById("fullAnswer").innerHTML="Atomic Number: 2 &amp;lt;br&amp;gt; Atomic Mass: 4.00260 amu &amp;lt;br&amp;gt; Group: 18 &amp;lt;br&amp;gt; Electronic Configuration: 1s"+'2'.sup();
    }
    else if(classNameShow=="Lithium"){
        document.getElementById("fullAnswer").innerHTML="Atomic Number: 3 &amp;lt;br&amp;gt; Atomic Mass: 6.941 amu &amp;lt;br&amp;gt; Group: 1 &amp;lt;br&amp;gt; Electronic Configuration: [He] 2s"+'1'.sup();
    }
    else if(classNameShow=="Beryllium"){
        document.getElementById("fullAnswer").innerHTML="Atomic Number: 4 &amp;lt;br&amp;gt; Atomic Mass: 9.01218 amu &amp;lt;br&amp;gt; Group: 2 &amp;lt;br&amp;gt; Electronic Configuration: [He] 2s"+'2'.sup();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Observe this code again and notice the predicted class name. This class name is linked with Atomic number, Atomic mass, group number and electronic configuration. For exhibiting these properties, remember to create a separate container in HTML and update it's content by changing it's class name.&lt;/p&gt;

&lt;h3&gt;
  
  
  To show the full content
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Showing containers 
document.getElementById("webcam-container").className = "";
document.getElementById("label-container").className = "";
document.getElementById("fullAnswer").className="";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  To hide the content
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Hiding containers
document.getElementById("webcam-container").className = "d-none";
document.getElementById("label-container").className = "d-none";
document.getElementById("fullAnswer").className="d-none";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe43pmbsux3or115argoq.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe43pmbsux3or115argoq.jpeg" alt="Image in webcam"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Provide input by uploading images
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Functions used in uploading images involves showing the answer whenever file is chosen, otherwise it is hidden or removed.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function openUploadImage() {
    //Showing elements
    document.getElementById("inp").className = "";
    document.getElementById("canvas").className = "";
    document.getElementById("fullAnswer").className="";

    //Changing button text
    upButton.textContent = "Close";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function closeUploadImage() {
    labelContainer = document.getElementById("label-container");
    let canvas = document.getElementById("canvas"),input = document.getElementById("inp");

    //Hiding input
    input.className = "d-none";
    input.value = null;

    //Removing Label
    labelContainer.className = "d-none";
    if (labelContainer.children.length &amp;gt; 0)
        labelContainer.removeChild(labelContainer.children[0]);
    canvas.className = "d-none";

    //Removing and changing the answer
    document.getElementById("fullAnswer").innerHTML="";
    document.getElementById("fullAnswer").className="d-none";

    //Clear canvas
    const context = canvas.getContext("2d");
    context.clearRect(0, 0, canvas.width, canvas.height);

    upButton.textContent = "Upload Image";    
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now, we should implement the upload image handler, the process is similar to the previous one. Basically, we caught the image on the input file, drew it into a canvas and then requested the Teachable Machine prediction for the element.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Uploading Image

document.getElementById("inp").onchange = function (e) {
    var img = new Image();
    img.onload = draw;
    img.onerror = failed;
    img.src = window.URL.createObjectURL(this.files[0]);
};
async function draw() {
    var canvas = document.getElementById("canvas");
    canvas.width = this.width;
    canvas.height = this.height;
    var ctx = canvas.getContext("2d");
    ctx.drawImage(this, 0, 0);

    const modelURL = URL + "model.json";
    const metadataURL = URL + "metadata.json";

    model = await tmImage.load(modelURL, metadataURL);
    maxPredictions = model.getTotalClasses();

    labelContainer = document.getElementById("label-container");
    labelContainer.appendChild(document.createElement("div"));

    labelContainer.className = "";
    await predict(canvas);
}
function failed() {
    console.error("The provided file couldn't be loaded as an Image media");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fywiefiltp0iwjid3l6ag.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fywiefiltp0iwjid3l6ag.jpg" alt="Image from files"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Video of the working of QuantumX
&lt;/h1&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/3xo3d4HTYm8"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h1&gt;
  
  
  Closing Remarks
&lt;/h1&gt;

&lt;p&gt;Initially, I was taking a lot of time to get a good idea to be implemented with SashiDo and Teachable machine. As I have a Chemistry class in my college along with other Computer Sciences, I had decided to integrate them in some way. Then I decided to implement the modern periodic table elements with Techable machine's image model that not only integrates with Chemistry but also helps beginners to memorize these elements with properties such as atomic number, atomic mass, group number and electronic configuration which are more frequently used in exams. &lt;/p&gt;

&lt;p&gt;While implementing the idea, I had to learn JavaScript and a little bit of Parse, which gave me confidence to proceed with my project. Whenever I was struck in between, I would mail SashiDo about any errors after which Veselina Staneva from SashiDo would help me with the errors. I am ever thankful for SashiDo, Vesi and Irena for giving me this opportunity to bring out my own creative ideas and helping me with creating it. I want to thank Vesi Staneva specially for giving me more than enough time to complete the project as well as this tutorial. Also, I want to thank my lovely and smart sister, &lt;a href="https://dev.to/vaishnavi5183"&gt;Vaishnavi&lt;/a&gt; for helping me in anything at anytime during this intern. &lt;/p&gt;

&lt;p&gt;I hope this tutorial helps you in implementing the similar ideas that you want to do with teachable machine in your websites. I very much recommend you to use SashiDo as it provides backend, ready to use API's, cloud service and UI/UX design editors in dashboard itself. Not only that it provides a database to store and manipulate the data for login or signup and others for your application. They are friendly and sociable people who will guide you throughout the project. It is a place to see when you want to create and develop applications in your favourite programming languages. Just concentrate on the idea and implement it then SashiDo will handle the rest for you!&lt;/p&gt;

&lt;h1&gt;
  
  
  Useful links
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://github.com/Haripriya2002145/QuantumX" rel="noopener noreferrer"&gt;Project in GitHub&lt;/a&gt;&lt;br&gt;
&lt;a href="https://haripriya2002145.github.io/QuantumX/" rel="noopener noreferrer"&gt;Web-App link&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.sashido.io/en/" rel="noopener noreferrer"&gt;SashiDo&lt;/a&gt;&lt;br&gt;
&lt;a href="https://blog.sashido.io/sashidos-getting-started-guide/" rel="noopener noreferrer"&gt;SashiDo Getting Started Guide&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=p0bGHP-PXD4" rel="noopener noreferrer"&gt;Build a responsive website&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=X8NFkUQNeek" rel="noopener noreferrer"&gt;Build a responsive website from scratch&lt;/a&gt;&lt;br&gt;
&lt;a href="https://teachablemachine.withgoogle.com/" rel="noopener noreferrer"&gt;Teachable Machine&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/SashiDo/awesome-teachable-machine" rel="noopener noreferrer"&gt;The Awesome Teachable Machine list&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.parseplatform.org/" rel="noopener noreferrer"&gt;Parse Documentation&lt;/a&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
