Skip to content

lenna-project/yolo-plugin

Repository files navigation

yolo-plugin

Lenna Yolo Plugin

This plugin runs the yolo model to label objects in images.

Test it on lenna.app.

🚴 Usage

You can test the lib by detecting objects in two images.

cargo run

The results are:

dog

person

🔬 Test in Headless Browsers with wasm-pack test

wasm-pack test --node

python version

The plugin can build python bindings.

build

Create a virtual environment for python.

virtualenv -p python3 .venv
source .venv/bin/activate
pip install .

usage

Import lenna_mobilenet_plugin in a python environment.

from PIL import Image
from numpy import asarray
import lenna_yolo_plugin
print(lenna_yolo_plugin.description())

image = Image.open('assets/dog.jpg')
data = asarray(image)
print(data.shape)

config = lenna_yolo_plugin.default_config()
processed = lenna_yolo_plugin.process(config, data)
print(processed.shape)
Image.fromarray(processed).save('lenna_test_out.png')

test

Run the python test file which loads the lenna.png and converts it.

pip install pillow numpy
python src/test.py

jupyter notebook

Find an example in example.ipynb

pip install jupyter
jupyter notebook example.ipynb

performance

The yolo model runs build with tract:

time cargo test default --release --no-default-features --features=yolo

real    0m0,499s
user    0m0,379s
sys     0m0,123s

Yolov8 Model Person Output

The yolov8 model runs build with candle:

time cargo test default --release --no-default-features --features=yolo

real    0m0,660s
user    0m1,346s
sys     0m0,099s

Yolov8 Model Person Output

Sources:

The model is from tiny-yolov2 on onnx.

The class names are from voc names on darknet.

The yolov8 model is from Candle Yolo Example licensed under MIT.

Paper

"YOLO9000: Better, Faster, Stronger" arXiv:1612.08242