googlecreativelab / teachablemachine-community

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

How to run pose estimation inference on video instead of webcam? #234

Open eevans1118 opened 3 years ago

eevans1118 commented 3 years ago

I am attempting to run a pose classification model that I trained on a video file, but I can't seem to figure out how to get it working with anything other than the documentation they provide for running inference on webcam input. I am trying to run the model using their provided javascript example code. I added an html video element and specified the height and width parameters, but I can't figure out how to get the predictions working in async function predict(). I commented out the webcam setup provided in the original code, and changed all webcam.canvas objects to video.canvas. I'm pretty new to javascript but the model only exports as tensorflow.js so that's what I have to work with. Any tips would be appreciated!

This is the error that is thrown: teachablemachine-pose.min.js:58 Uncaught (in promise) TypeError: Cannot read property 'height' of undefined at y (teachablemachine-pose.min.js:58) at Object.e.padAndResizeTo (teachablemachine-pose.min.js:58) at t. (teachablemachine-pose.min.js:51) at teachablemachine-pose.min.js:34 at Object.next (teachablemachine-pose.min.js:34) at teachablemachine-pose.min.js:34 at new Promise () at r (teachablemachine-pose.min.js:34) at t.estimatePoseOutputs (teachablemachine-pose.min.js:51) at t. (teachablemachine-pose.min.js:51)

fustyles commented 3 years ago

Please refer to my code. https://github.com/fustyles/webduino/blob/master/TensorFlow/TeachableMachine_video/TeachableMachine_video_localfile.html

Try it https://fustyles.github.io/webduino/TensorFlow/TeachableMachine_video/TeachableMachine_video_localfile.html