How to load a Teachable Machine pose model from project files in nodejs

Viewed 876

I trained a pose model on teachablemachine.withgoogle.com. I downloaded the model, so now I have a model.json, metadata.json, and weights.bin. I want to use this model in an Electron app, and I want to load it from my project file instead of downloading it from a Google Teachable Machine URL every time I open the app. Is there a way to do that? Right now, I have

let weightsURL = path.join(__dirname, '/posemodel/weights.bin')
let modelURL = path.join(__dirname, '/posemodel/model.json')
let metaDataURL = path.join(__dirname, '/posemodel/metadata.json')
model = await tmPose.loadFromFiles(modelURL, weightsURL, metaDataURL)

but I know that the loadFromFiles method requires the user to upload the file, which isn't what I want. When I package the app, the model will be within the app, so does anyone know how I can use it?

1 Answers

Simply use the load method and use the path to where those files are in your project:

model = await tmPose.load('assets/model.json', 'assets/metadata.json');
Related