Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
426 views
in Technique[技术] by (71.8m points)

tensorflow - SSD mobile net v2 does not detect objects on android

i trained a tensorflow model (SSD MOBILE NET V2) and converted to tflite to detect on android using tensorflow object detection demo app but the model does not detect any object`

0

021-01-28 16:25:30.228 15761-15761/org.tensorflow.lite.examples.detection E/tensorflow: CameraActivity: Exception! java.lang.IllegalStateException: This model does not contain associated files, and is not a Zip file. at org.tensorflow.lite.support.metadata.MetadataExtractor.assertZipFile(MetadataExtractor.java:325) at org.tensorflow.lite.support.metadata.MetadataExtractor.getAssociatedFile(MetadataExtractor.java:165) at org.tensorflow.lite.examples.detection.tflite.TFLiteObjectDetectionAPIModel.create(TFLiteObjectDetectionAPIModel.java:126) at org.tensorflow.lite.examples.detection.DetectorActivity.onPreviewSizeChosen(DetectorActivity.java:99) at org.tensorflow.lite.examples.detection.CameraActivity.onPreviewFrame(CameraActivity.java:200) at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1288) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:213) at android.app.ActivityThread.main(ActivityThread.java:8178) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101) 2021-01-28 16:25:30.669 15761-15782/org.tensorflow.lite.examples.detection W/System: A resource failed to call close. 2021-01-28 16:25:30.669 15761-15782/org.tensorflow.lite.examples.detection W/System: A resource failed to call close. 2021-01-28 16:25:33.898 15761-15761/org.tensorflow.lite.examples.detection D/AwareBitmapCacher: handleInit switch not opened pid=15761 2021-01-28 16:31:38.394 15761-15761/org.tensorflow.lite.examples.detection I/Camera: close camera: 0, package name: org.tensorflow.lite.examples.detection 2021-01-28 16:31:38.403 15761-15761/org.tensorflow.lite.examples.detection I/HwCameraUtil: notifySurfaceFlingerCameraStatus : isFront = false , isOpend = false 2021-01-28 16:31:38.500 15761-15761/org.tensorflow.lite.examples.detection D/tensorflow: CameraActivity: onPause org.tensorflow.lite.examples.detection.DetectorActivity@a34eeb3 2021-01-28 16:31:39.002 15761-15818/org.tensorflow.lite.examples.detection W/libEGL: EGLNativeWindowType 0x78af41ff50 disconnect failed 2021-01-28 16:31:39.081 15761-15761/org.tensorflow.lite.examples.detection D/tensorflow: CameraActivity: onStop org.tensorflow.lite.examples.detection.DetectorActivity@a34eeb3 2021-01-28 16:31:39.317 15761-15816/org.tensorflow.lite.examples.detection D/ZrHung.AppEyeUiProbe: not watching, wait. 2021-01-28 16:31:39.565 15761-15761/org.tensorflow.lite.examples.detection D/tensorflow: CameraActivity: onDestroy org.tensorflow.lite.examples.detection.DetectorActivity@a34eeb3 2021-01-28 16:31:39.567 15761-15761/org.tensorflow.lite.examples.detection D/ActivityThread: Remove activity client record, r= ActivityRecord{f78d8da token=android.os.BinderProxy@2fd533b {org.tensorflow.lite.examples.detection/org.tensorflow.lite.examples.detection.DetectorActivity}} token= android.os.BinderProxy@2fd533b`

question from:https://stackoverflow.com/questions/65940576/ssd-mobile-net-v2-does-not-detect-objects-on-android

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Look like your model don't contain any metadata as the embed model has.

May be the easiest way is to just remove this block:

    try (BufferedReader br =
        new BufferedReader(
            new InputStreamReader(
                metadata.getAssociatedFile(labelFilename), Charset.defaultCharset()))) {
      String line;
      while ((line = br.readLine()) != null) {
        Log.w(TAG, line);
        d.labels.add(line);
      }
    }

And just read the d.labels from the lableFilename (labelmap.txt in the assets folder).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...