YOLO

cat detected by yolo

Description

Note: the YOLO module is being deprecated, please refer to the ObjectDetector module.

You only look once (YOLO) is a state-of-the-art, real-time object detection system.

From the creators website:

Prior detection systems repurpose classifiers or localizers to perform detection. They apply the model to an image at multiple locations and scales. High scoring regions of the image are considered detections.

We use a totally different approach. We apply a single neural network to the full image. This network divides the image into regions and predicts bounding boxes and probabilities for each region. These bounding boxes are weighted by the predicted probabilities. Source

This implementation is heavily derived from ModelDepot.

Quickstart

  1. const video = document.getElementById('video');
  2. // Create a YOLO method
  3. const yolo = ml5.YOLO(video, modelLoaded);
  4. // When the model is loaded
  5. function modelLoaded() {
  6. console.log('Model Loaded!');
  7. }
  8. // Detect objects in the video element
  9. yolo.detect((err, results) => {
  10. console.log(results); // Will output bounding boxes of detected objects
  11. });

Usage

Initialize

  1. const yolo = ml5.YOLO();
  2. // OR
  3. const yolo = ml5.YOLO(video);
  4. // OR
  5. const yolo = ml5.YOLO(video, ?options, ?callback)
  6. // OR
  7. const yolo = ml5.YOLO(?options, ?callback)

Parameters

  • video: Optional. A HTML video element or a p5 video element.
  • options: Optional. An object describing a model accuracy and performance. For MobileNet this are: { filterBoxesThreshold: 0.01, IOUThreshold: 0.4, classProbThreshold: 0.4 }
  • callback: Optional. A function to run once the model has been loaded. If no callback is provided, it will return a promise that will be resolved once the model has loaded.

Properties


.isPredicting

Boolean. Boolean to check if the model is currently predicting



.modelReady

Object. Boolean to check if the model has loaded


Methods


.detect()

Given an image or video, returns an array of objects containing class names, bounding boxes and probabilities.

  1. yolo.detect(?input, ?callback);

📥 Inputs

  • input: A HTML video or image element or a p5 image or video element. If no input is provided, the default is to use the video given in the constructor.
  • callback: A function to run once the model has made the prediction. If no callback is provided, it will return a promise that will be resolved once the model has made a prediction.

📤 Outputs

  • Object: returns an array of objects containing class names, bounding boxes and probabilities.

Examples

p5.js

p5 web editor

plain javascript

Demo

No demos yet - contribute one today!

Tutorials

No tutorials yet - contribute one today!

Acknowledgements

Contributors:

  • Cristobal Valenzuela

Credits:

  • Paper Reference | Website URL | Github Repo | Book reference | etc

Source Code