DEV Community

Discussion on: How to detect objects in videos in a web browser using YOLOv8 neural network and JavaScript

Collapse
 
khannomaan profile image
Nomaan • Edited

Hi,
Thank you for your article, it has been a very big help to my project.

I am using python server to run my html page.
I have downloaded and added the ort-wasm-simd.wasm file to the same directory as my index.html file from the link you provided in an earlier reply but I am still getting the errors that I have attached herewith.

I have also imported the ort-min.js using importScripts function in my worker.js file .

Could you please help me solve this problem ?
Image description

Collapse
 
andreygermanov profile image
Andrey Germanov

Hi

Sorry, but I can't read the text of the error message. Can you add bigger screenshot?

Collapse
 
khannomaan profile image
Nomaan • Edited
Thread Thread
 
khannomaan profile image
Nomaan

The above error has been resolved (Thank you for your help) but the code is drawing the boxes in random places.
I wanted to ask if this code will work for 800X800 size images, since my onnx file accepts input of 800X800.

Thread Thread
 
andreygermanov profile image
Andrey Germanov

The standard YOLOv8 model accepts 640x640 images, so, the code resizes any image to 640x640 before processing, and then scales the boxes using this size in mind.

To make it work with 800x800 size, you need to replace all occurrences of the "640" number to "800" in the "prepare_input", "run_model" and "process_output" functions.

Thread Thread
 
Sloan, the sloth mascot
Comment deleted
 
andreygermanov profile image
Andrey Germanov • Edited

Sorry, Django is out of scope here.
If the solution works standalone, then the problem is definitely on the Django end. Search how to correctly integrate static web pages with JavaScript and external links to Django.

Thread Thread
 
khannomaan profile image
Nomaan

After the model runs for a couple of minutes, these error is logged in the console and the model stops working until its refreshed again.

This is the error it is throwing.

Image description

Thread Thread
 
andreygermanov profile image
Andrey Germanov

What do you have on line 12 of the "worker.js" ?

Thread Thread
 
andreygermanov profile image
Andrey Germanov

Haven't experienced this, but seems that this is a bug in some version of onnxruntime-web, that others experienced on different models: github.com/xenova/transformers.js/...

Try to update ort-wasm-simd.wasm to last version and use last version of ort.min.js.

Collapse
 
andreygermanov profile image
Andrey Germanov • Edited

Yes, this is a common problem. It means that the 'ort-min.js' and 'ort-wasm-simd.wasm' are from different versions of the ONNX runtime.

You need to download and use both files from the same version. When the article was written it was 1.15.1, but now it is 1.17.1.

Download both files from last ONNX runtime distribution:

cdn.jsdelivr.net/npm/onnxruntime-w...

Include them and try again.

Collapse
 
khannomaan profile image
Nomaan

Hi I included the latest files and that error has been resolved but I am facing another error now.

Image description