在 iOS 上实施 TensorFlow Attention OCR

Implementing TensorFlow Attention OCR on iOS

我已成功训练(使用 Inception V3 权重作为初始化)此处描述的 Attention OCR 模型:https://github.com/tensorflow/models/tree/master/attention_ocr 并将生成的检查点文件冻结到图表中。如何在 iOS 上使用 C++ API 实现此网络?

提前致谢。

根据其他人的建议,您可以使用一些现有的 iOS 演示 (1, 2) 作为起点,但要密切注意以下细节:

  1. 确保使用正确的工具 "freeze" 模型。 SavedModel 是 Tensorflow 模型的通用序列化格式。
  2. 模型导出脚本通常可以进行某种输入规范化。请注意,Model.create_base 函数需要一个形状为 [batch_size、高度、宽度、通道] 的 tf.float32 张量,其值归一化为 [-1.25, 1.25]。如果您将图像归一化作为 TensorFlow 计算图的一部分,请确保图像以非归一化方式传递,反之亦然。
  3. 要获取 input/output 张量的名称,您可以简单地打印它们,例如导出脚本中的某处:

    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)