Error While Trying To Load Tensorflow.js Model

Let me try…Thanks a lot for taking a look. I’ll let you know what happens once I host it there.

@yaustar the bin file won’t show a raw link on github, when I click view raw it just downloads.

You shouldn’t need the raw link to the bin file as it’s co-located with the json file. As long as you have the raw URL to the JSON file, it should be fine

1 Like

Getting this error with my setup in PlayCanvas:

https://playcanvas.com/project/731178/overview/neural-net-from-forums

I used weightUrlConverter to tell it where to find the URL for the bin files.

See: https://js.tensorflow.org/api/latest/#loadLayersModel

I think that’s to do with the input shape vector, and the neural net loads fine. I just need to reshape the vector now. Thanks a lot for your help.

EDIT - Finally got the test result alerted!

1 Like

@yaustar, it works perfectly now, but the result is getting alerted in every scene? I’ve even removed the script from root, but it’s still getting alerted. Never had this issue before, may be a bug?

EDIT - Problem persists after clearing cache.

EDIT 2 - I deleted the script after saving it to local system, and the problem is gone. Is it because of how async functions are treated in JS, that even if the scripts are removed, they’ll still run? I am at a slight loss here.

Not sure what you mean. It will always run no matter which scene you start up in because you called the code and function in global scope.

The code provided is not scoped to any Entity or any scene.

Not a bug, no.

So ideally I should call the predict function in the init function?

Depends on your requirements. If you want it so it is called when only a particular entity in a particular scene is created, creating a pc.script that calls the function is fine.

1 Like