NPM package for TensorFlow.js models exported from Custom Vision Service
npm install customvision-tfjs
<img id="image" src="test_image.jpg" />
import * as cvs from 'customvision-tfjs';
let model = new cvs.ClassificationModel();
await model.loadModelAsync('model.json');
const image = document.getElementById('image');
const result = await model.executeAsync(image);
The result is a 1D-array of probabilities.
import * as cvs from 'customvision-tfjs';
let model = new cvs.ObjectDetectionModel();
await model.loadModelAsync('model.json');
const image = document.getElementById('image');
const result = await model.executeAsync(image);
The result has 3 arrays.
[
[[0.1, 0.3, 0.4, 0.3], [0.2, 0.4, 0.8, 0.9]], // bounding boxes (x1, y1, x2, y2)
[0.2, 0.3], // probabilities
[1, 4] // class ids
]