tfjs-yolo
YOLO
object detection with Tensorflow.js. Supports YOLO v3 and Tiny YOLO v1, v2, v3.
Demo
Install
npm install tfjs-yolo
Usage
Import module
import yolo from 'tfjs-yolo';
Initialize and load model
let myYolo = await yolo.v1tiny();
let myYolo = await yolo.v2tiny();
let myYolo = await yolo.v3tiny();
let myYolo = await yolo.v3();
let myYolo = await yolo.v3tiny("https://.../model.json");
let myYolo = await yolo.v3tiny(
"https://.../weights_manifest.json",
"https://.../tensorflowjs_model.pb"
);
Run model
Supported input html element:
const boxes = await myYolo.predict(canvas);
const boxes = await myYolo.predict(
canvas,
{
maxBoxes: 5,
scoreThreshold: .2,
iouThreshold: .5,
numClasses: 80,
anchors: [...],
classNames: [...],
inputSize: 416,
}
);
Output box format
{
top,
left,
bottom,
right,
height,
width,
score,
class
}
Dispose model
myYolo.dispose();
Credits