Skip to content

Instantly share code, notes, and snippets.

@mugifly
mugifly / image-predict-on-tfjs-node.js
Last active January 7, 2024 16:11
Image Prediction on tfjs-node (with model made by Teachable Machine Image)
const tf = require('@tensorflow/tfjs-node');
const Jimp = require('jimp');
// Directory path for model files (model.json, metadata.json, weights.bin)
// NOTE: It can be obtained from [Export Model] -> [Tensorflow.js] -> [Download my model]
// on https://teachablemachine.withgoogle.com/train/image
const MODEL_DIR_PATH = `${__dirname}`;
// Path for image file to predict class
const IMAGE_FILE_PATH = `${__dirname}/example.jpg`;