Tensorflow JS Inference error

I’m having a problem deploying my model on the browser.

Are you already make sure to call initialize function? It’s look like your model not loaded yet.

1 Like

Yes


Are you awaiting for initialize to complete before trying to call model.predict? It seems your model is not ready yet when you try and call this function. If you can link us to live demo that would be helpful as hard to see from screenshots what state is at runtime.

1 Like

Hi Jason :slightly_smiling_face: , I always watching your content on tensorflowjs. I’m having difficulties on deploying my custom model on the browser.I try to find a tutorial on Tensorflow site but there’s no tutorial on running a custom model on the browser. I find this tutorial tfjs-model but it just shows only how to load the transfer learning model mobilenet and make an inference.

Here’s the live demo : code demo

Looking at the console output it seems you are pointing to files that do not exist. Please point to correct locations of files and let me know when to check again. Thanks.

Failed to load resource: the server responded with a status of 404 ()
classifier.js:1 Failed to load resource: the server responded with a status of 404 ()
fiddle.jshell.net/weights/catsvsdogs/model.json:1 Failed to load resource: the server responded with a status of 404 ()
http.js:149 Uncaught (in promise) Error: Request to /weights/catsvsdogs/model.json failed with status code 404. Please verify this URL points to the model JSON of the model to load.
    at t.<anonymous> (http.js:149)
    at u (runtime.js:45)
    at Generator._invoke (runtime.js:274)
    at Generator.forEach.t.<computed> [as next] (runtime.js:97)
    at Wm (runtime.js:728)
    at o (runtime.js:728)
classifier.css:1 Failed to load resource: the server responded with a status of 404 ()

PS regards tutorials, these are similar enough that show how to take a saved model and use in web browser:

You can obviously skip the python conversion bit and got to where I upload the model.json and bin files linked above.

I also made a Firebase deployment guide too:

The error still cannot predict property

Here’s my project structure:

Here’s the updated code : code demo

You still have 404 errors trying to load files indicating you are pointing to incorrect path which you need to resolve first:

GET https://fiddle.jshell.net/static/classifier.css net::ERR_ABORTED 404
fiddle.jshell.net/:330 GET https://fiddle.jshell.net/static/classifier.js net::ERR_ABORTED 404
fiddle.jshell.net/:296 GET https://fiddle.jshell.net/static/classifier.css net::ERR_ABORTED 404
fiddle.jshell.net/:330 GET https://fiddle.jshell.net/static/classifier.js net::ERR_ABORTED 404
platform_browser.js:28 GET https://fiddle.jshell.net/ef7dhrvm/show/model_v1/model.json 404
(anonymous) @ platform_browser.js:28
e @ platform_browser.js:27
(anonymous) @ http.js:146
u @ runtime.js:45
(anonymous) @ runtime.js:274
forEach.t.<computed> @ runtime.js:97
Wm @ runtime.js:728
o @ runtime.js:728
(anonymous) @ runtime.js:728
(anonymous) @ runtime.js:728
(anonymous) @ http.js:202
(anonymous) @ models.js:280
u @ runtime.js:45
(anonymous) @ runtime.js:274
forEach.t.<computed> @ runtime.js:97
Wm @ runtime.js:728
o @ runtime.js:728
(anonymous) @ runtime.js:728
(anonymous) @ runtime.js:728
iT @ models.js:328
aT @ models.js:269
(anonymous) @ models.js:256
u @ runtime.js:45
(anonymous) @ runtime.js:274
forEach.t.<computed> @ runtime.js:97
Wm @ runtime.js:728
o @ runtime.js:728
(anonymous) @ runtime.js:728
(anonymous) @ runtime.js:728
rT @ models.js:256
(anonymous) @ exports.js:235
t.loadLayersModel @ exports.js:237
initialize @ ?editor_console=:387
(anonymous) @ ?editor_console=:480
Show 4 more frames
http.js:149 Uncaught (in promise) Error: Request to model_v1/model.json failed with status code 404. Please verify this URL points to the model JSON of the model to load.
    at t.<anonymous> (http.js:149)
    at u (runtime.js:45)
    at Generator._invoke (runtime.js:274)
    at Generator.forEach.t.<computed> [as next] (runtime.js:97)
    at Wm (runtime.js:728)
    at o (runtime.js:728)