yolov5

1.0.11 • Public • Published

YOLO v5 in Node.JS

Object Detection using YOLO for Node.js backend.

ES6 compatibile

Installation

npm i yolov5

It also installs the required dependencies: tfjs, tfjs-node and regenerator-runtime

For more info on tensorflow backend in node.js:
(https://github.com/tensorflow/tfjs/tree/master/tfjs-node) (https://github.com/tensorflow/tfjs)

Usage

require('regenerator-runtime');
const yolov5 =  require('yolov5');
// import {YOLOv5s} from 'yolov5';


const main = async() => {	
	let predictions;

	const yolo = yolov5;		// Create an instance of the model 
	await yolo.load();			// Load Model 

	if (yolo.model != '') {
		console.log("Model loaded \n");
		const result = await yolo.predict(image);		// Input image must be in 640x640 format 
		predictions = yolo.getDetections(result);		// Get bounding box(s) and class data 
	} else {
		return console.error("Model not found \n");
	}

	if (predictions.length > 0) console.log("Predictions:", predictions);
	
	yolo.dispose;
};

main();

View model parameters, methods, functions: console.log(yolo.details())

Output

Prediction format:

{
	"bbox": [409, 1, 639, 169],		// [x0, y0, x1, y1]
	"score": 0.6489,				// probability score
	"class": "car"					// Object class name
}

Notes

  • Current backend support only for CPU via tfjs-node.

  • Insert regenerator-runtime or its equivalent for async-await based functional implementation.

Package Sidebar

Install

npm i yolov5

Weekly Downloads

2

Version

1.0.11

License

MIT

Unpacked Size

29.2 MB

Total Files

16

Last publish

Collaborators

  • smajum