Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @cloud-annotations/models with all npm packages installed. Try it out:

var models = require("@cloud-annotations/models")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@cloud-annotations/models v0.1.1

Cloud Annotations models for TensorFlow.js

Cloud Annotations JavaScript SDK

NPM Version NPM Downloads

The Cloud Annotations SDK makes it easy to use your custom trained object detection or classification models in the browser or on the backend with TensorFlow.js. Simply load() your model_web folder and pass the loaded model a <canvas>, <img> or <video> reference.

Installation

npm install @cloud-annotations/models

Usage

Load a model

import models from '@cloud-annotations/models'

const model = await models.load('/model_web')

Object detection

const img = document.getElementById('img')
const predictions = await model.detect(img)

// predictions =>
[{
  label: 'dog',
  bbox: [x, y, width, height],
  score: 0.92
},
{
  label: 'cat',
  bbox: [x, y, width, height],
  score: 0.72
}]

Classification

const img = document.getElementById('img')
const predictions = await model.classify(img)

// predictions =>
[
  { label: 'dog', score: 0.92 },
  { label: 'cat', score: 0.72 }
]

Usage via Script Tag

No npm install required. Just import via the script tag.

<script src="https://cdn.jsdelivr.net/npm/@cloud-annotations/models"></script>
<script>
  const img = document.getElementById('img')
  models.load('/model_web')
    .then(model => model.detect(img))
    .then(predictions => {
      console.log(predictions)
    })
</script>

Example usage: Real-Time Object Detection With React.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free