Contains material for a TensorFlow.js workshop.
Presentation slides at:
https://docs.google.com/presentation/d/1jHkbAQHWIXM7clDwTCzlqPPbnAd4xRoDo34sp6OHe_A/edit?usp=sharing
$ git clone [email protected]:Machine-Learning-Tokyo/tfjs-workshop.git
To install nodejs, using nvm is recommended.
They are simple application of image classification using MobileNet which is a light weight model for image classification.
Web application demonstrating image classfication using MobileNet. The application classified the given image. The initial model will be downloaded from TensorFlow Hub that is a registry for publishing pretrained deep learning models.
$ cd web
# Or
$ cd web-js
$ yarn
$ npx parcel src/index.html --open
It will automatically launch the webapp to classify the given image. Please look into index.html to change the image to be predicted. That application is based on MobileNet demo in tfjs-models.
Now you can your own model in Google Colab with the image you have. Please refer to the instruction in colab notebook. You can upload a image as the dataset used for training.
tfjs-converter is a tool to make a model readable by TensorFlow.js from pre-trained model by TensorFlow. It supports SavedModel, Keras model and so on. The colab gives you the model in the format imporable to TensorFlow.js.
The application can load the pre-trained model in tfjs_layers_model
. After the application is launched, the model should be put in the dist
directory so that the application can load the model. You can find the template to create the loadable model in Google Colab.
$ cp -R ~/Downloads/mymobilenet.zip dist
$ cd dist && unzip mymobilenet.zip
$ npx parcel src/index.html --open
It is also necessary to change the code to switch the loaded model.
You can publish the application in the internet by using GitHub pages. Please follow the instruction in GitHub pages to bootstrap the site. Once the repository is prepared, copy the artifacts of the application in dist
to the repository.
$ cd username.github.io
$ mv /path/to/tfjs-workshop/web/dist .
$ git add --all
$ git commit -m "Initial commit"
$ git push -u origin master
Then your will see the application in http://username.github.io
.