Page 362 - Kaleidoscope Academic Conference Proceedings 2024
P. 362

2024 ITU Kaleidoscope Academic Conference




                12. TENSORFLOW.JS IMPLEMENTATION

           12.1  Requirements:

           The conversion procedure requires a Python environment,
           we need to keep an isolated one using pipenv or virtualenv.        Figure 9– Use Model

            Importing a Keras model into TensorFlow.js is a two-step
           process. First, convert an existing Keras model to TF.js
           Layers format, and then load it into TensorFlow.js.

           12.1.1  Step 1:

            Convert an existing Keras model to TF.js Layers format.
           Use the Python API to export directly to TF.js Layers
           format. As we have a Keras trained model in Python, we are
           exporting it directly to theTensorFlow.js Layers format as
           follows:













                            Figure 7– Step-1

           12.1.2  Step 2:

            Load the model into TensorFlow.js by providing the URL
           to the model.json file:









                            Figure 8– Step-2

           Now the model is ready for inference, evaluation, or re-
           training. For instance, the loaded model can be immediately
           used to make a prediction: We have taken this approach, so
           that pre-trained model can easily be hosted on any Cloud
           Storage Platform.










           This approach allows all of these files to be cached by the
           browser (and perhaps by additional caching servers on the
           internet), because the model.json and the weight shards are
           each smaller than the typical cache file size limit. Thus a
           model is likely to load more quickly on subsequent
           occasions.




                                                          – 318 –
   357   358   359   360   361   362   363   364   365   366   367