Skip to content

Instantly share code, notes, and snippets.

@olokobayusuf
Last active January 30, 2022 20:31
Embed
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}`);
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment