Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

ModelDepot/tfjs-yolo-tiny

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡️ Fast In-Browser Object Detection 👀

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

SupportsTiny YOLO, as of right now,tfjs does not havesupport to run any full YOLO models (and your user's computers probablycan't handle it either).

Demo

Check out the Live Demo

(You can only get so far with 1 FPS)

yolo person detection

Install

Yarn

yarn add tfjs-yolo-tiny

Or NPM

npm install tfjs-yolo-tiny

Usage Example

importyolo,{downloadModel}from'tfjs-yolo-tiny';constmodel=awaitdownloadModel();constinputImage=webcam.capture();constboxes=awaityolo(inputImage,model);// Display detected boxesboxes.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)

Args

ParamTypeDefaultDescription
inputtf.Tensor-Expected shape (1, 416, 416, 3) Tensor representing input image (RGB 416x416)
modeltf.Model-Tiny YOLO tf.Model
[options]ObjectSee BelowOptional, Additional Configs

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

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

OptionTypeDefaultDescription
[options.classProbThreshold]Number0.4Filter out classes below a certain threshold
[options.iouThreshold]Number0.4Filter out boxes that have an IoU greater than this threadhold (refer to tf.image.nonMaxSuppression)
[options.filterBoxesThreshold]Number0.01Threshold to filter out box confidence * class confidence
[options.maxBoxes]Number2048Number of max boxes to return, refer to tf.image.nonMaxSuppression. Note: The model itself can only return so many boxes.
[options.yoloAnchors]tf.TensorSee src/postprocessing.js(Advanced) Yolo Anchor Boxes, only needed if retraining on a new dataset
[options.width]Number416(Advanced) If your model's input width is not 416, only if you're using a custom model
[options.height]Number416(Advanced) If your model's input height is not 416, only if you're using a custom model
[options.numClasses]Number80(Advanced) If your model has a different number of classes, only if you're using a custom model
[options.classNames]Array.<String>See src/coco_classes.js(Advanced) If your model has non-MSCOCO class names, only if you're using a custom model

Returns

Returns an array of objects.

PropertyTypeDescription
topNumberPixels from top of image where bounding box starts
leftNumberPixels from left of image where bounding box starts
bottomNumberPixels from top of image where box ends.
rightNumberPixels from left of image where box ends.
classProbNumberProbability of the class in the bounding box.
classNameStringHuman name of the class.

downloadModel(url)

Args

ParamTypeDefaultDescription
urlstringSee DEFAULT_MODEL_LOCATIONTiny YOLO Model config path. Seetf.loadModel

Returns

Returns aPromise that can resolve to atf.Model.

Contributing

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

Install Dependencies

yarn install

Run Tests

If you're running tests, make sure toyarn add @tensorflow/tfjs@0.7.0so 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 thelocal version oftfjs intead of the peer version.

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

yarn test

Build

yarn build

Or during development, use watch mode, you can use thedemo appto test out changes.

yarn watch

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2026 Movatter.jp