googlecreativelab / teachablemachine-community

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

Prediction are different in tensorflow.js from the web one #321

Closed mehdish3022 closed 1 year ago

mehdish3022 commented 1 year ago

I've trained a model on multiple classes and it worked very well when I tested it on the web but when I imported my model to a local tensorflowjs the predictions were completely wrong.

sryu1 commented 1 year ago

I'm guessing it'll be because the js snippet is outdated, if possible, can you just check if it works if you use the keras snippet? You need python though, just to check that the model is fine...

mehdish3022 commented 1 year ago

It does work with keras tensorflow but I want to use it with tensorflowjs

sryu1 commented 1 year ago

Ok, then it's a problem with the tfjs snippet, I'll try looking into it, however, if you find a way to make it work, it'll be appreciated :)

mehdish3022 commented 1 year ago

I converted the model into a tensorflowjs graph model and it kinda works but the predictions are wrong and sometimes inefficient

sryu1 commented 1 year ago

It's the problem with the tensorflowjs code snippet, not the model itself, since the keras model is actually originally a tfjs model but converted to keras.

mehdish3022 commented 1 year ago

How do I solve this problem?

sryu1 commented 1 year ago

Could you try using the snippet from my repo here? https://github.com/sryu1/teachablemachine-community/blob/master/snippets/markdown/image/tensorflowjs

mehdish3022 commented 1 year ago

Could you try using the snippet from my repo here? https://github.com/sryu1/teachablemachine-community/blob/master/snippets/markdown/image/tensorflowjs

it works now