Using Javascript to load ONNX model for Object Detection job
source link: https://donghao.org/2023/07/28/using-javascript-to-load-onnx-model-for-object-detection-job/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Using Javascript to load ONNX model for Object Detection job
Although having used the YOLOv5 model several times, I haven’t used its corresponding ONNX model before. This time, I met a use case to run its ONNX model using Javascript.
To learn and debug the code, I installed node.js and started my Javascript trip. This snippet helps me a lot to understand the Non-Max Suppression algorithm again (I used NMS algo many years). After studying it and also the implementation in the YOLOv5, I finally knocked together the Javascript code to use the ONNX model of YOLOv5 to detect objects:
Why the “YOLOV5S_CLASSES” is 85? That’s because in YOLO series it uses the first four floats as coordinates of boxes (center x, center y, width, height), the fifth as “object confidence”, and the left 80 floats as “class confidence”.
For anyone who is interested in it, you could use the below steps to run:
- Install node.js on your computer or laptop
- Run npm install fs inkjet onnxruntime-node to install js packages
- Run node detect.js lorikeet.jpg to detect objects in the image “lorikeet.jpg” and output to file “output.txt”
- Run python3 draw.py lorikeet.jpg to show the image of the result by using data in “output.txt”
Hope it could be useful for someone.
Related Posts
- Choosing a Object Detection Framework written by Tensorflow
Recently I need to train a DNN model for object detection task. In the past,…
- Grab a hands-on realtime-object-detection tool
Try to get a fast (what I mean is detecting in lesss than 1 second…
- Model saving error when using Apex
Apex is a tool to enable mixed-precision training that comes from Nvidia. import apex.amp as…
July 28, 2023 - 4:00
RobinDong
machine learning
YOLOv5
Leave a comment
Leave a Reply Cancel reply
Your email address will not be published. Required fields are marked *
Comment *
Name *
Email *
Website
Save my name, email, and website in this browser for the next time I comment.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK