customvision-tfjs
NPM package for TensorFlow.js models exported from Custom Vision Service
Install
npm install customvision-tfjs
Usage
<img id="image" src="test_image.jpg" />
Classification
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.
Object Detection
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]],
[0.2, 0.3],
[1, 4]
]