I have some code for tensorflow showing the confidence and the class name, but I only want to show the most confident result

Viewed 24
    // run the webcam image through the image model
    async function predict() {
        // predict can take in an image, video or canvas html element
        const prediction = await model.predict(webcam.canvas);
        for (let i = 0; i < maxPredictions; i++) {
 //join class name and confidence of class             
        const classPrediction = prediction[i].className + ": " + prediction[i].probability.toFixed(2);
            //put class in html
labelContainer.childNodes[i].innerHTML = classPrediction;
        }
    }

the link to the code is at:https://replit.com/@MichaelMarchin2/simpler-facial-recognition#script.js

0 Answers
Related