我正在使用ML套件集成对象检测,正在使用Firebase ML创建自定义tflite模型,并遵循此文档https://firebase.google.com/docs/ml-kit/android/use-custom-models来加载自定义模型,但在加载模型时出现错误
com.google.firebase.ml.common.FirebaseMLException:本地模型加载失败,并带有以下模型选项:本地模型名:modelname。远程型号名称:未指定。
private fun configureLocalModelSource() {
// [START mlkit_local_model_source]
val localSource = FirebaseLocalModel.Builder("my_local_model") // Assign a name to this model
.setAssetFilePath("my_model.tflite")
.build()
FirebaseModelManager.getInstance().registerLocalModel(localSource)
// [END mlkit_local_model_source]
}
@Throws(FirebaseMLException::class)
private fun createInterpreter(): FirebaseModelInterpreter? {
// [START mlkit_create_interpreter]
val options = FirebaseModelOptions.Builder()
.setRemoteModelName("my_cloud_model")
.setLocalModelName("my_local_model")
.build()
val interpreter = FirebaseModelInterpreter.getInstance(options)
// [END mlkit_create_interpreter]
return interpreter
}