在将转换后的TFLite模型加载到android应用程序时遇到问题。
型号:Deeplabv3 Mobilenetv2(在Pascal VOC上进行了培训)TFLite版本:1.10
使用tflite_convert将pb文件转换为tflite。(Tensorflow版本:1.11.0)
码:
private MappedByteBuffer loadModelFile(AssetManager assets, String modelFilename)
throws IOException {
AssetFileDescriptor fileDescriptor = assets.openFd(modelFilename);
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);
}
/**
* Initializes a native TensorFlow session for classifying images.
*
* @param assetManager The asset manager to be used to load assets.
* @param modelFilename The filepath of the model GraphDef protocol buffer.
*/
public static Segmentor create( …Run Code Online (Sandbox Code Playgroud)