

This will convert the model at /tmp/model.h5 and output a model.json file along with binary weight files to your tmp/tfjs_model/ directory. To convert your model using the TensorFlow.js converter, you can run the following command: $ tensorflowjs_converter -input_format=keras /tmp/model.h5 /tmp/tfjs_model For example, let’s say you have saved a Keras model named model.h5 to your tmp/ directory. The model library can be found here.ĭepending on which type of model you’re trying to convert, you’ll need to pass different arguments to the converter.

TensorFlow Hub module: These are models that have been packaged for distribution on TensorFlow Hub, a platform for sharing and discovering models. More information about saving Keras models can be found here. Keras model: Keras models are generally saved as an HDF5 file. The SavedModel format is documented here. SavedModel: This is the default format in which TensorFlow models are saved. The TensorFlow.js converter works with several different model formats: An API for loading and executing the model in the browser with TensorFlow.js.A command line utility that converts Keras and TensorFlow models for use in TensorFlow.js.The TensorFlow.js converter has two components: TensorFlow.js provides a model converter for this purpose. However you may have found or authored a TensorFlow model elsewhere that you’d like to use in your web application. With that, you are all set to use TypeScript to convert your existing JavaScript comes with a variety of pre-trained models that are ready to use in the browser - they can be found in our models repo. Once you've made all the above changes to your JavaScript project, run your build tool and you should have your TypeScript project compiled into plain JavaScript that you can run in the browser. All you need to do is install the types for each of the libraries used in your project.įor example, for Jquery, install the definition: npm install list of all available TypeScript Type definitions can be seen here. So, we don't need to add types to these ourselves. TypeScript needs to know the types of all objects in these libraries in order to compile files.įortunately, TypeScript Type definition files for most JavaScript libraries are already available at DefinitelyTyped. Most JavaScript projects use third-party libraries like jQuery or Lodash.
