In this section, we are going to deploy the model on a browser.
The following steps demonstrate how to save the model:
- Install TensorFlow.js, which will help us format our trained model in accordance with what can be consumed by the browser:
pip install tensorflowjs
- Save the model in the TensorFlow.js format:
import tensorflowjs as tfjs tfjs.converters.save_keras_model(model, OUTPUT_DIR)
This will create a json file called model.json
, which will contain the meta-variables and some other files, such as group1-shard1of1
.
Good job! Deploying the model in the HTML file is a little trickier, however:
Note
For running the code mentioned in the repository, please follow the README.md
documentation carefully (note the troubleshooting part, if required) regarding the settings before running the Run_On_Browser.html
file.
- Incorporate TensorFlow.js in your JavaScript through script tags:
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]">...