How to train a model in nodejs tensorflow js

0 votes

I'd like to create an image classifier, however I'm not familiar with Python. I'm familiar with javascript, which Tensorflow.js uses. Can it be used to train models, and how would it work? Sincerely, I don't know where to begin.

The only thing I figured out was how to use "mobilenet," which is ostensibly a collection of models that have already been trained, to import images and classify them:

const tf = require('@tensorflow/tfjs'),
      mobilenet = require('@tensorflow-models/mobilenet'),
      tfnode = require('@tensorflow/tfjs-node'),
      fs = require('fs-extra');

const imageBuffer = await fs.readFile(......),
      tfimage = tfnode.node.decodeImage(imageBuffer),
      mobilenetModel = await mobilenet.load();  

const results = await mobilenetModel.classify(tfimage);

which works, but it's no use to me because I want to train my own model using my images with labels that I create.

=======================

Say I have a bunch of images and labels. How do I use them to train a model?

const myData = JSON.parse(await fs.readFile('files.json'));

for(const data of myData){
  const image = await fs.readFile(data.imagePath),
        labels = data.labels;

  // how to train, where to pass image and labels ?

}
Aug 19, 2022 in Node-js by Neha
• 9,020 points
881 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Node-js

0 votes
1 answer

How to print a stack trace in Node.js?

Hello @kartik, To print stacktrace of Error in console in ...READ MORE

answered Jul 9, 2020 in Node-js by Niroj
• 82,840 points
884 views
0 votes
1 answer

How to host a Node.Js application in shared hosting?

Hello @kartik, You can run node.js server on a typical ...READ MORE

answered Jul 17, 2020 in Node-js by Niroj
• 82,840 points
7,256 views
0 votes
1 answer

How to print a stack trace in Node.js?

Hello @kartik, Any Error object has a stack member that traps the ...READ MORE

answered Jul 20, 2020 in Node-js by Niroj
• 82,840 points
2,899 views
0 votes
1 answer

How to update a value in a json file and save it through node.js?

Hello @kartik, It's particularly useful if you're concerned ...READ MORE

answered Oct 12, 2020 in Node-js by Niroj
• 82,840 points
25,981 views
0 votes
1 answer

How to run app.js in nodejs?

Hello @kartik, Assuming I have node and npm properly installed on the ...READ MORE

answered Oct 13, 2020 in Node-js by Niroj
• 82,840 points
3,021 views
0 votes
1 answer

How to provide a mysql database connection in single file in nodejs?

Hello @kartik, You could create a db wrapper ...READ MORE

answered Oct 15, 2020 in Node-js by Niroj
• 82,840 points
9,123 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,942 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,468 views
0 votes
1 answer

Start script missing error when running npm start

It seems that there is an undefined ...READ MORE

answered Feb 10, 2022 in Java by Soham
• 9,710 points
4,459 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP