Deploying a new version of your model

The real power of Fritz exists in the automatic download of revised model files. Here, we will demonstrate this.

So far, we have uploaded our old (a+b)2 model and performed the inference. Now, we will update it to (a+b)3 and check whether our app automatically downloads the revised model.

For that, we need to create the (a+b)3 model. First, we need to recall our Creating and saving model section under Chapter 4TensorFlow Mobile in Android, where we created the (a+b)2 model. We are going to make a small change that will convert this model:


import tensorflow as tf

a = tf.placeholder(tf.int32, name='a') # input
b = tf.placeholder(tf.int32, name='b') # input
times = tf.Variable(name="times", dtype=tf.int32, initial_value=3)
c = tf.pow(tf.add(a, b), times, name="c")

saver = tf.train.Saver()
init_op = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init_op)

tf.train.write_graph(sess.graph_def, '.', 'tfdroid.pbtxt')
sess.run(tf.assign(name="times", value=3, ref=times))
# save the graph

# save a checkpoint file, which will store the above assignment
saver.save(sess, './tfdroid.ckpt')
In the preceding program, the only change we have made is to the value of the times variable, which is now 3. This will result in multiplying (a+b) by three, which gives (a+b)3. Please refer to Chapter 4TensorFlow Mobile in Android, for instructions on how to run and generate the .pb extension model file.

Once you get the frozen_tfdroid.pb file, you can upload this from the Fritz web console of your model page, as shown in the following screenshot:

Expand the Add Updated Model pane and upload the generated model. It will add as version 2 in the right-hand side table:

Now you have uploaded a revision of the model, but you haven't published it yet. To do so, you need to expand the Release New Version pane and release the version you need.

Once you do that, all the mobile devices that installed your app will download the released model when they get an internet connection through a WiFi network.

Here is the result I got when I connected to my WiFi router and restarted the app:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset