ml5js / ml5-library

Friendly machine learning for the web! 🤖
https://ml5js.org
Other
6.38k stars 906 forks source link

A problem occurs when trying to load my custom mobilenet model. #1442

Open MohammadNusir opened 1 year ago

MohammadNusir commented 1 year ago

Dear ml5 community,

I'm submitting a new issue. Please see the details below. ------------------------------------------------>

I'm trying to load my custom ml5 in my react js website, however, I'm facing some issues when I try to load the model. For instance, if I write the following code:

classifier.load('''../EcommarceApp/appAIModel/model.json'',custModelReady);
function custModelReady(){
  console.log(' Custom Model Loaded!');
  gotResults()
}

the following error occurred:

Screenshot 2022-12-21 091521

However, When I try to import the model:

import customModel from ''../EcommarceApp/appAIModel/model.json'',
classifier.load(customModel,custModelReady);
function custModelReady(){
  console.log(' Custom Model Loaded!');
  gotResults()
}

I usually get the following error:

Screenshot 2022-12-21 092208

Also Here is my full code:

Screenshot 2022-12-21 092421

Please help me I'm completely lost.

----------------------------------------->

sproutleaf commented 10 months ago

Hi @MohammadNusir ,

Thank you for opening the issue with us! Can you share a link to your whole project (i.e. on GitHub), so that I can take a look at the code more closely?

Without looking at all the code though, here are some of my 2c re: the errors:

  1. Status code 404 means the server cannot find the webpage you have requested. Check where you tried to open a webpage in the code and see if the URL is valid.
  2. Uncaught TypeError: Failed to execute 'readAsText' on 'FileReader': parameter 1 is not of type 'Blob' usually happens when you call readAsText on a hard-coded string, instead of a Blob or File. See official documentation here. Some useful StackOverflow questions include this and this.

Miaoye