我已经基于 MobilenetV2 创建了一个新的tflite模型。它可以很好地工作,而无需在iOS上使用CPU进行量化。我应该说TensorFlow团队做得很好,非常感谢。
不幸的是,延迟存在问题。我使用iPhone5s测试我的模型,所以对于CPU我有以下结果:
具有224 * 224输入图像的MobilenetV2 500ms。
具有160 * 160输入图像的MobilenetV2 250-300ms。
我使用了以下pod'TensorFlowLite','〜> 1.13.1'
这还不够,所以我阅读了与优化(训练后量化)相关的TF文档。我想我需要使用Float16或UInt8量化和GPU委托(请参阅https://www.tensorflow.org/lite/performance/post_training_quantization)。 我使用 Tensorflow v2.1.0 训练和量化模型。
https://github.com/tensorflow/examples/tree/master/lite/examples/image_segmentation/ios
没有错误,但模型不起作用
2020-05-01 21:36:13.578369 + 0300 TFL分段[6367:330410]初始化了TensorFlow Lite运行时。 2020-05-01 21:36:20.877393 + 0300 TFL分段[6367:330397]由于执行期间出错,命令缓冲区的执行被中止。导致GPU挂起错误(IOAF代码3)
pod“ TensorFlowLiteGpuExperimental”
代码示例:https://github.com/makeml-app/MakeML-Nails/tree/master/Segmentation%20Nails
我在uint8量化后使用了MobilenetV2模型。
GpuDelegateOptions options;
options.allow_precision_loss = true;
options.wait_type = GpuDelegateOptions::WaitType::kActive;
//delegate = NewGpuDelegate(nullptr);
delegate = NewGpuDelegate(&options);
if (interpreter->ModifyGraphWithDelegate(delegate) != kTfLiteOk)
Segmentation Live [6411:331887] [DYMTLInitPlatform]平台初始化成功 加载模型1已解决的报告程序找不到内置操作码“ PAD”版本“ 2”的操作
是否可以通过某种方式在IOS上使用MObilenetV2量化模型?希望我犯了一些错误:)并且有可能。
最好的问候, 德米特里
答案 0 :(得分:0)
对不起的文档过时了- created() {
db.collection('users').get().then((snapshot) => {
let usersArray = [];
snapshot.forEach((doc) => {
const user = doc.data();
user.id = doc.id;
usersArray.push(user);
console.log(user.documents.selfie.url); // Here the log return the value correctly
});
this.users = usersArray;
});
},
2.1.0中应包含GPU委托。但是,看起来您正在使用C API,因此仅依靠TensorFlowLiteSwift
就可以了。
MobileNetV2可以在iOS中与TFLite运行时一起使用,如果我没记错的话,它没有PAD op。您可以附加模型文件吗?有了提供的信息,很难知道是什么导致了错误。作为健全性检查,您可以从这里获取MobileNetV2的定量/非定量版本:https://www.tensorflow.org/lite/guide/hosted_models
对于int8量化模型-afaik GPU委托仅适用于FP32和(可能)FP16输入。
答案 1 :(得分:0)
这是GITHUB问题的链接,其答案为:https://github.com/tensorflow/tensorflow/issues/39101