首页 > 解决方案 > Which is faster when deploying cnn models by TensorFlow Lite, Caffe2 or OpenCV?

问题描述

We can deploy MobileNet on Smartphone by TensorFlow Lite, Caffe2 or OpenCV, and I think Caffe2 will provide the best performance with higher fps. But why? Is the performance gap between them so large? Thanks.

标签: opencvtensorflowcaffetensorflow-litecaffe2

解决方案


您可能应该选择 TensorFlow Lite。最后我看了一下,Caffe2 对智能手机 GPU 的支持几乎为零,而 TFLite 现在支持 iOS 和许多 Android 设备(所有具有 OpenGLES >=3.1 的设备)。使用 GPU 通常会使事情快几倍,并且您可以使用 TFLite 将推理精度降低到半浮点 (FP16) 以获得更高的速度并且不会对性能造成太大影响。

当您无法使用移动 GPU 时,您可能希望将您的网络量化为 int8,这在 TensorFlow 和 TensorFlow Lite 中很容易实现,无论是在训练期间还是训练之后。Caffe2 似乎需要 QNNPACK 进行量化,据称速度快 2 倍。问题是它仅适用于他们发布的两个预训练模型(https://github.com/pytorch/QNNPACK/issues/12),因此您无法转换自己的模型。

所以我真的想不出在 TFLite 上使用 Caffe2 的理由。

我不确定 OpenCV 的 DNN 模块,但我严重怀疑它是否支持移动 GPU。量子化的可能性很小。


推荐阅读