Implementing TensorFlow Attention OCR on iOS

家住魔仙堡 提交于 2019-12-25 09:24:46

问题


I have successfully trained (using Inception V3 weights as initialization) the Attention OCR model described here: https://github.com/tensorflow/models/tree/master/attention_ocr and frozen the resulting checkpoint files into a graph. How can this network be implemented using the C++ API on iOS?

Thank you in advance.


回答1:


As suggested by others you can use some existing iOS demos (1, 2) as a starting point, but pay close attention to the following details:

  1. Make sure you use the right tools to "freeze" the model. The SavedModel is a universal serialization format for Tensorflow models.
  2. An model export script can and usually do some kind of input normalization. Note that the Model.create_base function expects a tf.float32 tensor of shape [batch_size, height, width, channels] with values normalized to [-1.25, 1.25]. If you do image normalization as part of the TensorFlow computation graph, make sure images are passed unnormalized and vise versa.
  3. To get names of input/output tensors you can simply print them, e.g. somewhere in your export script:

    data_images = tf.placeholder(dtype=tf.float32, shape=[batch_size, height, width, channels], name='normalized_input_images')
    endpoints = model.create_base(data_images, labels_one_hot=None)
    print(data_images, endpoints.predicted_chars, endpoints.predicted_scores)
    


来源:https://stackoverflow.com/questions/44990104/implementing-tensorflow-attention-ocr-on-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!