googlecreativelab / teachablemachine-community

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

[BUG]: npm install and import is not work in React #326

Open moqoru opened 1 year ago

moqoru commented 1 year ago

Hi! I'm making some project with this fancy library, but now I'm stuck with React translations.

I made some pose examples with Teachable Machine Website, and I exported them with the specific URL. And I tried to make some React .jsx file from the original HTML file.

But after I npm-installed both @tensorflow/tfjs and @teachablemachine/pose libraries and started the webpage, they didn't work properly.

Here's my terminal errors in VSCode and React (using Win 10), React1 and here's my web errors in Chrome Console, when I clicked the button. React2

Can you solve this problem?

Moritz-Dilg commented 11 months ago

I am facing the same issue. Have you found a solution?

Garreta11 commented 1 month ago

Hi @moqoru and @Moritz-Dilg

I have the same problem and I just wanted to ask you if you could manage to solve it. Thanks a lot.

Moritz-Dilg commented 1 month ago

Hi @Garreta11,

as far as I can remember, this is an issue with conflicting TensorFlow versions, but I could be wrong.

After realizing this, I went ahead and discarded TM and built everything with MediaPipe. See this Website for more info. After I got the poses from MediaPipe, I used the knn Classifier from tensorflow. This solution ended up working great for me. If you have any more questions on how exactly I did this, I'll be happy to help.

Hope this helps ;)