Skip to content

Instantly share code, notes, and snippets.

Last active January 30, 2022 20:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Testing our NatML Hub predictor in NodeJS
import { MLModelData, MLImageFeature } from "natml"
import { ResNet18HubPredictor } from "../src"
async function main () {
// Fetch the model from NatML Hub
const modelData = await MLModelData.fromHub("@natsuite/resnet18", process.env.ACCESS_KEY);
const model = modelData.deserialize();
// Create the predictor
const predictor = new ResNet18Predictor(model);
// Predict
const feature = new MLImageFeature("cat.jpg");
const [label, score] = await predictor.predict(feature);
console.log(`Image contains ${label} with confidence ${score}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment