This is an example transfer learning application for classifying images into cats and dogs based on Tensorflow.js for Node.js.
It's using a KNN Classifier on top of Mobilenet.
I'm using yarn in my examples but you could use npm as well.
-
Get all dependencies.
yarn install
-
Train the model. This will use input data from
./data/train
and export the trained model to./knn-model.js
. You can simply replace the data in those folders and adjust the./data/index.js
to your needs.yarn train
-
Test the trained model. This will import the trained model and test it with data from
./data/test
. Wrong classifications will be printed in the console.yarn test
Used cats and dogs sample data is taken from this repository by swimaugers.