googlecreativelab / teachablemachine-community

Example code snippets and machine learning code for Teachable Machine
https://g.co/teachablemachine
Apache License 2.0
1.51k stars 682 forks source link

Saved audio model incorrectly triggers ' Error: Unsupported URL scheme in metadata URL' #60

Open ToonTalk opened 4 years ago

ToonTalk commented 4 years ago

The following occurs with localhost and also at https://ecraft2learn.github.io/ai/teachablemachine/sound/

./my_model/metadata.json is https:// but isn't recognized as such

(index):57 Uncaught (in promise) Error: Unsupported URL scheme in metadata URL: ./my_model/metadata.json. Supported schemes are: http://, https://, and (node.js-only) file:// at speech-commands.min.js:17 at speech-commands.min.js:17 at Object.next (speech-commands.min.js:17) at speech-commands.min.js:17 at new Promise () at i (speech-commands.min.js:17) at speech-commands.min.js:17 at e. (speech-commands.min.js:17) at speech-commands.min.js:17 at Object.next (speech-commands.min.js:17)

HalfdanJ commented 4 years ago

Tensorflow.js requires that you specify the protocol when loading a model, so you need to expand that path to the full path of where you are hosting the model file, including http / https

I can see we do introduce this issue in the snippet, will create a ticket for updating the snippet to a path that illustrates it.

ToonTalk commented 4 years ago

Thanks. Just curious why this is required only for the audio example. The same './my_model/metadata.json' works fine for the image and posenet snippets.

irealva commented 4 years ago

Adding in @caisq.

I think this is because of this line in speech commands: throw new Error

We changed how we were handling image and pose metadata checks to account for the case of someone loading a model locally like './my_model/metadata'.