【问题标题】:tflite models from tfhub.dev not working in Androidtfhub.dev 中的 tflite 模型无法在 Android 中运行
【发布时间】:2021-02-22 12:33:23
【问题描述】:

我正在尝试使用 TensorFlow 在 android 中使用自定义模型检测,并且我正在使用来自官方 TensorFlow 站点的预训练模型。 4 个模型中有 3 个无法在日志中显示此错误。

E/CameraXDetectionActivit: onFailure: 
    com.google.mlkit.common.MlKitException: Failed to initialize detector. Unexpected number of dimensions for output index 0: got 3D, expected either 2D (BxN with B=1) or 4D (BxHxWxN with B=1, W=1, H=1).
        at com.google.mlkit.vision.vkp.PipelineManager.start(com.google.mlkit:vision-internal-vkp@@18.0.0:63)
        at com.google.mlkit.vision.objects.custom.internal.zzg.tryLoad(com.google.mlkit:object-detection-custom@@16.3.1:3)
        at com.google.mlkit.common.sdkinternal.model.CustomModelLoader.load(com.google.mlkit:common@@17.1.1:3)
        at com.google.mlkit.vision.objects.custom.internal.zzh.load(com.google.mlkit:object-detection-custom@@16.3.1:2)
        at com.google.mlkit.common.sdkinternal.ModelResource.zza(Unknown Source:18)
        at com.google.mlkit.common.sdkinternal.zzn.run(Unknown Source:10)
        at com.google.mlkit.common.sdkinternal.zzp.run(com.google.mlkit:common@@17.1.1:2)
        at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zze(com.google.mlkit:common@@17.1.1:4)
        at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zzc(Unknown Source:8)
        at com.google.mlkit.common.sdkinternal.zzj.run(Unknown Source:2)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at com.google.mlkit.common.sdkinternal.MlKitThreadPool.zzd(Unknown Source:10)
        at com.google.mlkit.common.sdkinternal.zzk.run(Unknown Source:2)
        at java.lang.Thread.run(Thread.java:919)

我试过的型号是:

aiy/vision/classifier/birds_V1(工作中)

efficientdet/lite0/detection(不工作)

ssd_mobilenet_v1(不工作)

Mobile object_localizer_v1.1(不工作)

【问题讨论】:

    标签: android tensorflow


    【解决方案1】:

    您似乎正在使用 ML Kit 的对象检测 API 和 custom model。它首先识别图像中的对象,然后对这些对象运行图像分类以确定对象是什么。因此,模型的输出是类别概率。

    另一方面,其他模型是实际的对象检测模型,并输出代表边界框位置和类别的四个张量。

    使用这些检测模型请参考以下示例。

    https://www.tensorflow.org/lite/examples/object_detection/overview

    【讨论】:

      猜你喜欢
      • 2021-12-16
      • 2021-08-03
      • 2019-12-01
      • 1970-01-01
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多