by ModelDepot

ModelDepot / tfjs-yolo-tiny

In-Browser Object Detection using Tiny YOLO on Tensorflow.js

452 Stars 86 Forks Last release: Not found MIT License 16 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

⚡️ Fast In-Browser Object Detection 👀

Detect objects in images right in your browser using Tensorflow.js! Currently takes ~800ms to analyze each frame on Chrome MBP 13" mid-2014.


, as of right now,
does not have support to run any full YOLO models (and your user's computers probably can't handle it either).


Check out the Live Demo

(You can only get so far with 1 FPS)

yolo person detection



yarn add tfjs-yolo-tiny


npm install tfjs-yolo-tiny

Usage Example

import yolo, { downloadModel } from 'tfjs-yolo-tiny';

const model = await downloadModel(); const inputImage = webcam.capture();

const boxes = await yolo(inputImage, model);

// Display detected boxes boxes.forEach(box => { const { top, left, bottom, right, classProb, className, } = box;

drawRect(left, top, right-left, bottom-top, ${className} ${classProb}) });

API Docs

yolo(input, model, options)



Type Default Description
input tf.Tensor - Expected shape (1, 416, 416, 3) Tensor representing input image (RGB 416x416)
model tf.Model - Tiny YOLO tf.Model
[options] Object See Below Optional, Additional Configs

If you're using a custom Tiny YOLO model or want to adjust the default filtering cutoffs, you may do so by passing an additional options object.


yolo(inputImage, model, { classProbThreshold: 0.8 });


Type Default Description
[options.classProbThreshold] Number 0.4
[options.iouThreshold] Number 0.4
[options.filterBoxesThreshold] Number 0.01
[options.maxBoxes] Number 2048
[options.yoloAnchors] tf.Tensor See src/postprocessing.js
[options.width] Number 416
[options.height] Number 416
[options.numClasses] Number 80
[options.classNames] Array.<String> See src/coco_classes.js


Returns an array of objects.


Type Description
top Number Pixels from top of image where bounding box starts
left Number Pixels from left of image where bounding box starts
bottom Number Pixels from top of image where box ends.
right Number Pixels from left of image where box ends.
classProb Number Probability of the class in the bounding box.
className String Human name of the class.




Type Default Description
url string See DEFAULTMODELLOCATION Tiny YOLO Model config path. See tf.loadModel


Returns a

that can resolve to a


PR's are more than welcome! Perf improvement or better test coverage are probably the two biggest areas of immediate need. If you have thoughts on extensibility as well, feel free to open an issue!

Install Dependencies

yarn install

Run Tests

If you're running tests, make sure to

yarn add @tensorflow/[email protected]
so that you you don't get tfjs package not found errors. If you're developing, make sure to remove tfjs as a dependency, as it'll start using the local version of
intead of the peer version.

Note: Test coverage is poor, definitely don't rely on them to catch your errors.

yarn test


yarn build

Or during development, use watch mode, you can use the demo app to test out changes.

yarn watch

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.