Alp*_*pha 6 tensorflow tensorflow-lite
我正在尝试将deeplab-v3 +模型转换为TF-Lite,我从mobilenetv2_coco_voc_trainaug下载了MobileNet-v2的预训练模态。
使用以下命令覆盖模型:
bazel run --config=opt \
//tensorflow/contrib/lite/toco:toco -- \
--input_file=/tmp/frozen_inference_graph.pb \
--output_file=/tmp/optimized_graph.tflite \
--input_format=TENSORFLOW_GRAPHDEF \
--output_format=TFLITE \
--input_type=QUANTIZED_UINT8 \
--input_arrays=ImageTensor \
--output_arrays=SemanticPredictions \
--input_shapes=1,513,513,3 \
--allow_custom_ops
Run Code Online (Sandbox Code Playgroud)
它已成功覆盖tflite模型,然后将其放入android资产文件夹并加载到android应用,我在gradle中进行了以下设置:
aaptOptions {
noCompress "tflite"
noCompress "lite"
}
Run Code Online (Sandbox Code Playgroud)
使用以下功能加载模型:
/** Memory-map the model file in Assets. */
private MappedByteBuffer loadModelFile(Activity activity) throws IOException {
AssetFileDescriptor fileDescriptor = activity.getAssets().openFd(MODEL_PATH);
FileInputStream inputStream = new FileInputStream(fileDescriptor.getFileDescriptor());
FileChannel fileChannel = inputStream.getChannel();
long startOffset = fileDescriptor.getStartOffset();
long declaredLength = fileDescriptor.getDeclaredLength();
return fileChannel.map(FileChannel.MapMode.READ_ONLY, startOffset, declaredLength);
}
Run Code Online (Sandbox Code Playgroud)
当调用tflite = new Interpreter(loadModelFile(activity));的问题发生,异常秀“ MappedByteBuffer是不是一个有效的flatbuffer模型 ”有人可以帮助弄清楚什么过程中,我做错了吗?toco工具中有错误吗?
| 归档时间: |
|
| 查看次数: |
952 次 |
| 最近记录: |