09.05.2023 Views

pdfcoffee

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 13

We have seen how to use TensorFlow.js within the browser. The next section will

explain how to convert a model from Keras into TensorFlow.js.

Converting models

Sometimes it is convenient to convert a model that has already been created with

tf.keras. This is very easy and can be done offline with the following command,

which takes a Keras model from /tmp/model.h5 and outputs a JavaScript model

into /tmp/tfjs_model:

tensorflowjs_converter --input_format=keras /tmp/model.h5 /tmp/tfjs_model

The next section will explain how to use pretrained models in TensorFlow.js.

Pretrained models

TensorFlow.js comes with a significant number of pretrained models for deep

learning with image, video, and text. The models are hosted on NPM, so it's very

simple to use them if you are familiar with Node development.

[ 485 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!