teachablemachine-community icon indicating copy to clipboard operation
teachablemachine-community copied to clipboard

Teachable machine pose model work with Tfjs React Native

Open danielchung928 opened this issue 5 years ago • 4 comments

May I know is it possible to use the Teachable machine exported pose model to integrate with the Tensorflow React Native module?

From the example code of Teachable machine pose model predict method:

async function predict() { // Prediction 1: run input through posenet // estimatePose can take in an image, video or canvas html element const { pose, posenetOutput } = await model.estimatePose(webcam.canvas); // Prediction 2: run input through teachable machine classification model const prediction = await model.predict(posenetOutput);

... }

In the React Native world, any idea how to get the "posenetOutput" from the TensorCamera and fit into the Teachable machine pose model predict method?

danielchung928 avatar Sep 07 '20 09:09 danielchung928

Hi,

Thanks so much for writing in.Are you trying to replicate our training code but using tfjs-react-native? If so, the pose itself is not the input to the training model, but another activation we're using which is here:

https://github.com/googlecreativelab/teachablemachine-community/blob/master/libraries/pose/src/custom-posenet.ts#L231

You would need to replicate the function we have there to generate the posenetOutput which is a concatenated tensor with the heatmap and offset vectors of posenet (they are the intermediate outputs of posenet before decoding the pose keypoints).

irealva avatar Oct 29 '20 21:10 irealva

Duplicate of #145

irealva avatar Oct 29 '20 21:10 irealva

Hello folks, can we use the camera from React Native with these libraries?

jdnichollsc avatar Mar 16 '21 20:03 jdnichollsc

Any update on this? Using tf.loadLayersModel(bundleResourceIO(modelJson, modelWeights)); is the best I've seen but can't use teachable machine automatic metadata etc. Btw, it isn't accurate with this technique

evanjmg avatar Jan 01 '23 21:01 evanjmg