Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

object detection on android with gpu will crash when set setCategoryAllowlist #5614

Closed
hugski opened this issue Sep 6, 2024 · 7 comments
Closed
Assignees
Labels
gpu MediaPipe GPU related issues platform:android Issues with Android as Platform task:object detection Issues related to Object detection: Track and label objects in images and video. type:bug Bug in the Source Code of MediaPipe Solution

Comments

@hugski
Copy link

hugski commented Sep 6, 2024

Have I written custom code (as opposed to using a stock example script provided in MediaPipe)

None

OS Platform and Distribution

android 13

Mobile device if the issue happens on mobile device

xiaomi pad 6 pro

Browser and version if the issue happens on browser

No response

Programming Language and version

kotlin java

MediaPipe version

com.google.mediapipe:tasks-vision:latest.release

Bazel version

No response

Solution

Object detection

Android Studio, NDK, SDK versions (if issue is related to building in Android environment)

No response

Xcode & Tulsi version (if issue is related to building for iOS)

No response

Describe the actual behavior

eg. setCategoryAllowlist("person") will crash and error message is "Check failed: class_index_set_.values.size() == IsClassIndexAllowed(0) ? num_classes_ : num_classes_ - 1 (1 vs. 90) Only all classes >= class 0 or >= class 1"

Describe the expected behaviour

setCategoryAllowlist("person") and the result only contain person categories

Standalone code/steps you may have used to try to get what you need

val baseOptions = BaseOptions.builder()
                .setDelegate(Delegate.GPU)
                .setModelAssetPath("detect/efficientdet-lite0.tflite")
                .build()

            val options = ObjectDetector.ObjectDetectorOptions.builder()
                .setBaseOptions(baseOptions)
                .setCategoryAllowlist(mutableListOf("person"))

Other info / Complete Logs

No response

@hugski hugski added the type:bug Bug in the Source Code of MediaPipe Solution label Sep 6, 2024
@kuaashish kuaashish added platform:android Issues with Android as Platform task:object detection Issues related to Object detection: Track and label objects in images and video. gpu MediaPipe GPU related issues labels Sep 9, 2024
@kuaashish
Copy link
Collaborator

Hi @hugski,

Could you please try using List instead of mutableListOf, as both should behave similarly, but we would like to test this approach just in case it resolves the issue?

Also, when using the CPU as the delegate, could you provide an update on the status?

Thank you!!

@kuaashish kuaashish added the stat:awaiting response Waiting for user response label Sep 11, 2024
Copy link

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale label Sep 19, 2024
@hugski
Copy link
Author

hugski commented Sep 19, 2024

@kuaashish

  1. changed mutableListOf to List, and the same issuse happen and the app crash
val baseOptions = BaseOptions.builder()
                .setDelegate(Delegate.GPU)
                .setModelAssetPath("detect/efficientdet-lite0.tflite")
                .build()

val options = ObjectDetector.ObjectDetectorOptions.builder()
    .setBaseOptions(baseOptions)
    .setCategoryAllowlist(listOf("person"))

the error message is

setCategoryAllowlist("person") will crash and error message is "Check failed: class_index_set_.values.size() == IsClassIndexAllowed(0) ? num_classes_ : num_classes_ - 1 (1 vs. 90) Only all classes >= class 0 or >= class 1"

  1. When Delegate changed to CPU, the app behave normally
val baseOptions = BaseOptions.builder()
                .setDelegate(Delegate.CPU)
                .setModelAssetPath("detect/efficientdet-lite0.tflite")
                .build()

val options = ObjectDetector.ObjectDetectorOptions.builder()
    .setBaseOptions(baseOptions)
    .setCategoryAllowlist(listOf("person"))

@google-ml-butler google-ml-butler bot removed stale stat:awaiting response Waiting for user response labels Sep 19, 2024
@kuaashish
Copy link
Collaborator

Hi @hugski,

Apologies for the delayed response. Could you please update to Android 14, as it supports API level 34, which is required in MediaPipe version 0.10.15. You can find more details in our release notes here under Android section 'Bump targetSdkVersion to 34 throughout MediaPipe.'

Additionally, please try the latest version (0.10.15) and let us know if the issue persists.

Thank you!!

@kuaashish kuaashish added the stat:awaiting response Waiting for user response label Oct 17, 2024
Copy link

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale label Oct 25, 2024
Copy link

github-actions bot commented Nov 1, 2024

This issue was closed due to lack of activity after being marked stale for past 7 days.

@github-actions github-actions bot closed this as completed Nov 1, 2024
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@kuaashish kuaashish removed stat:awaiting response Waiting for user response stale labels Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gpu MediaPipe GPU related issues platform:android Issues with Android as Platform task:object detection Issues related to Object detection: Track and label objects in images and video. type:bug Bug in the Source Code of MediaPipe Solution
Projects
None yet
Development

No branches or pull requests

2 participants