【发布时间】:2019-06-03 05:47:50
【问题描述】:
我目前正在研究单图像超分辨率,并且我设法冻结了现有的检查点文件并将其转换为 tensorflow lite。但是,使用 .tflite 文件进行推理时,对一张图像进行上采样所需的时间至少是使用 .ckpt 文件恢复模型时的 4 倍。
使用 .ckpt 文件的推理是使用 session.run() 完成的,而使用 .tflite 文件的推理是使用interpreter.invoke() 完成的。这两项操作都是在典型 PC 上运行的 Ubuntu 18 VM 上完成的。
为了了解更多有关该问题的信息,我在单独的终端中运行 top 以查看执行任一操作时的 CPU 利用率。 .ckpt 文件的利用率达到 270%,但 .tflite 文件的利用率保持在 100% 左右。
interpreter.set_tensor(input_details[0]['index'], input_image_reshaped)
interpreter.set_tensor(input_details[1]['index'], input_bicubic_image_reshaped)
start = time.time()
interpreter.invoke()
end = time.time()
对
y = self.sess.run(self.y_, feed_dict={self.x: image.reshape(1, image.shape[0], image.shape[1], ch), self.x2: bicubic_image.reshape(1, self.scale * image.shape[0], self.scale * image.shape[1], ch), self.dropout: 1.0, self.is_training: 0})
一个假设是 tensorflow lite 未配置为多线程,另一个假设是 tensorflow lite 针对 ARM 处理器(而不是我的计算机运行的 Intel 处理器)进行了优化,因此速度较慢。但是,我无法确定,我也不知道如何追查问题的根源 - 希望那里的人对此有更多的了解?
【问题讨论】:
标签: tensorflow tensorflow-lite