Я пытаюсь преобразовать модель deeplab-v3 + в TF-Lite, я загружаю предварительно обученные модалы с MobileNet-v2 из mobilenetv2_coco_voc_trainaug .
, используя команду ниже, чтобы покрытьмодель:
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
она успешно закрыта для модели tflite, затем я помещаю ее в папку активов Android и загружаю в приложение Android, я установил ниже в gradle:
aaptOptions {
noCompress "tflite"
noCompress "lite"
}
, используя функцию ниже, чтобызагрузить модель:
/** 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);
}
при вызове tflite = new Interpreter(loadModelFile(activity));
проблема возникает, исключение показывает " MappedByteBuffer не является допустимой моделью плоского буфера ", любой может помочь выяснить, какой процесс яделать неправильно?Есть ли ошибка в инструменте Токо?