我目前正在研究单图像超分辨率,并且设法冻结了现有的检查点文件并将其转换为tensorflow lite。但是,当使用.tflite文件执行推理时,对一幅图像进行升采样所花费的时间至少是使用.ckpt文件恢复模型时所花费的时间的四倍。
使用.ckpt文件的推理是使用session.run()完成的,而使用.tflite文件的推理是使用解释器.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()
Run Code Online (Sandbox Code Playgroud)
与
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})
Run Code Online (Sandbox Code Playgroud)
一种假设是没有为多线程配置tensorflow lite,另一种认为是针对ARM处理器(而不是我的计算机所运行的Intel处理器)优化了tensorflow lite,因此速度较慢。但是,我不能肯定地说,也不知道如何找到问题的根源-希望外面有人对此有更多的了解?