The saved, trained model, in the form of the model.pbtxt and model_ckpt files, cannot be used by the Android app directly. We need to convert it to an optimized protobuf format (a .pb extension file), which can be integrated with the Android app. The file size of the optimized protobuf format will be much smaller than the combined size of the model.pbtxt and model_ckpt files.
The following code(freeze_code.py) will create the optimized protobuf model from the model.pbtxt and the model_ckpt files:
# -*- coding: utf-8 -*-
import sys
import tensorflow as tf
from tensorflow.python.tools import freeze_graph
from tensorflow.python.tools import optimize_for_inference_lib
import fire
from elapsedtimer import ElapsedTimer
#path = '/home/santanu/Downloads/Mobile_App/'
#MODEL_NAME = 'model'
def model_freeze(path,MODEL_NAME='model&apos...