Page 337 - MDP2022-2
P. 337

<link  rel="preload"  as="style"  href="assets/mobirise/css/mbr-additional.css">
                    <link  rel="stylesheet"  href="assets/mobirise/css/mbr-additional.css"  type="text/css">
            </head>


            <body>
                    <div>Please  let  me  know  the  material.</div>
                    <a  href="/mdp/choice.html">back</a>
                    <div  class="col-auto  mbr-section-btn  align-center"><button  type="button"  class="btn
            btn-primary  display-4"
                                    onclick="init()">Start</button></div>
                    <div  id="webcam-container"></div>
                    <div  id="label-container"></div>
            </body>
            <script  src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.3.1/dist/tf.min.js"></script>
            <script
            src="https://cdn.jsdelivr.net/npm/@teachablemachine/image@0.8/dist/teachablemachine-image.m
            in.js"></script>
            <script  type="text/javascript">
                    const  foodType  =  {
                            'peper':  'vegetable',
                            'napa  cabbage':  'vegetable',
                            'Bean  sprouts':  'vegetable',
                            'pimento':  'vegetable',
                            'lettuce':  'vegetable',
                            'carrot':  'vegetable',
                            'apple':  'fruit',
                            'peach':  'fruit',
                            'shrimp':  'seafood',
                            'egg':  'egg',
                            'milk':  'dairy  produce',
                            'fish':  'fish',
                    }


                    const  URL  =  "./test/";
                    let  model,  webcam,  labelContainer,  maxPredictions;
                    async  function  init()  {
                            const  modelURL  =  URL  +  "model.json";
                            const  metadataURL  =  URL  +  "metadata.json";
                            model  =  await  tmImage.load(modelURL,  metadataURL);
                            maxPredictions  =  model.getTotalClasses();


                            const  flip  =  true;
                            webcam  =  new  tmImage.Webcam(200,  200,  flip);
                            await  webcam.setup();
                            await  webcam.play();
   332   333   334   335   336   337   338   339   340   341   342