Skip to content

Latest commit

 

History

History
86 lines (58 loc) · 1.94 KB

README_EN.md

File metadata and controls

86 lines (58 loc) · 1.94 KB

tfjs-yolov3

Introduction

A Tensorflow.js implementation of YOLOv3 and YOLOv3-tiny

Note: Must [email protected]+

Features

  • can recognize images of any size
  • Support both yolov3 and yolov3-tiny

Quick Start

Install

npm install tfjs-yolov3

Usage Example

import { yolov3, yolov3Tiny } from 'tfjs-yolov3'

async function start () {
  const yolo = await yolov3Tiny() // pre-load model (35M)
  // or
  // const yolo = await yolov3() // pre-load model (245M)

  const $img = document.getElementById('img')
  const boxes = await yolo($img) 
  draw(boxes) // Some draw function
}
start()

API DOC

The yolov3 and yolov3Tiny functions accept an options object and return a function

export declare function yolov3 (
  { modelUrl, anchors }? :
  { modelUrl?: string, anchors?: number[] }
): Promise<yolo>

export declare function yolov3Tiny (
  { modelUrl, anchors }? :
  { modelUrl?: string, anchors?: number[] }
): Promise<yolo>
Parameters Description
modelUrl Optional, pre-train the model's url, you can download the model to the local, speed up the loading of the pre-training model
anchors Optional, custom anchors, format referenceconfig

After the above two functions are called, the pre-training model will be loaded, and a function will be returned. This function can be used to identify the image and return the identified box list. The parameters are as follows:

type yolo = ($img: HTMLImageElement) => Promise<Box[]> 

interface Box {
  top: number
  left: number
  bottom: number
  right: number
  width: number
  height: number
  scores: number
  classes: string
}

DEMO

Check out the Live Demo

demo