January 2019
Intermediate to advanced
342 pages
9h 17m
English
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 sysimport tensorflow as tffrom tensorflow.python.tools import freeze_graphfrom tensorflow.python.tools import optimize_for_inference_libimport firefrom elapsedtimer import ElapsedTimer ...
Read now
Unlock full access