
TensorFlow.js Has a Free API That Runs Machine Learning Models in the Browser
TensorFlow.js brings Google's ML framework to JavaScript. Train models in Node.js, run inference in the browser — no Python needed. Pre-Trained Models: Zero Training import * as tf from " @tensorflow/tfjs " ; import * as mobilenet from " @tensorflow-models/mobilenet " ; // Image classification const model = await mobilenet . load (); const img = document . getElementById ( " product-image " ); const predictions = await model . classify ( img ); console . log ( predictions ); // [{ className: 'laptop', probability: 0.92 }] Object Detection import * as cocoSsd from " @tensorflow-models/coco-ssd " ; const model = await cocoSsd . load (); const predictions = await model . detect ( img ); predictions . forEach ( p => { console . log ( ` ${ p . class } : ${( p . score * 100 ). toFixed ( 1 )} %` ); console . log ( `Box: [ ${ p . bbox . join ( " , " )} ]` ); }); Text Toxicity Detection import * as toxicity from " @tensorflow-models/toxicity " ; const model = await toxicity . load ( 0.9 ); cons
Continue reading on Dev.to JavaScript
Opens in a new tab



