Testing our NatML Hub predictor in NodeJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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