question

Aoki-4614 avatar image
0 Votes"
Aoki-4614 asked PratulSharma-6841 published

Custom Vision Android sample applications does not work.

I want to get Custom Vision Object Detection working on my Android device.

First of all, I tried to get Object Detection to work with the following Azure sample.
https://github.com/Azure-Samples/cognitive-services-android-customvision-sample

However, the following error was output and the sample did not work.

 Caused by: ai.customvision.visionskills.VisionSkillsException: {"NativeRuntimeError":"Skill[ObjectDetector] Build Exception <JNIWrapperException: Failed to load model; Model name = <sample-tflite.cvmodel/cvexport.manifest>; details: java.lang.IncompatibleClassChangeError: Found interface org.tensorflow.lite.Tensor, but class was expected (declaration of 'org.tensorflow.lite.Tensor' appears in /data/app/demo.tensorflow.org.customvision_sample-NCBKza2LNIIq7gnDSEbZWQ==/base.apk!classes2.dex)>"}
    at ai.customvision.visionskills.VisionSkillsManager.throwIfJNIFailed(VisionSkillsManager.java:24)
    at ai.customvision.visionskills.VisionSkillsManager.SkillConfigurationBuild_orThrow(VisionSkillsManager.java:553)
    at ai.customvision.visionskills.VisionSkillsManager.skillConfigurationBuild(VisionSkillsManager.java:309)
    at ai.customvision.visionskills.ConfigurationBase.build(ConfigurationBase.java:41)
    at ai.customvision.visionskills.CVSObjectDetector$Configuration.build(CVSObjectDetector.java:66)
    at demo.tensorflow.org.customvision_sample.MSCognitiveServicesCustomVisionObjectDetector.<init>(MSCognitiveServicesCustomVisionObjectDetector.java:62)
    at demo.tensorflow.org.customvision_sample.ObjectDetectorActivity.onCreate(ObjectDetectorActivity.java:52)
    at android.app.Activity.performCreate(Activity.java:7802)
    at android.app.Activity.performCreate(Activity.java:7791)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409) 
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) 
    at android.os.Handler.dispatchMessage(Handler.java:107) 
    at android.os.Looper.loop(Looper.java:214) 
    at android.app.ActivityThread.main(ActivityThread.java:7356) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) 

In addition, I created a model myself and replaced it with the Sample model, but it still output an error and did not work.

I followed the guide below with the model set to Domains as General (compact) and exported the model on TensorFlow Android.
https://docs.microsoft.com/ja-jp/azure/cognitive-services/custom-vision-service/export-your-model


My environment is below.
--Android Studio Arctic Fox | 2020.3.1 Patch 3
--VD: Android 10.0 x86
--Android API 29

build.gradle:

 apply plugin: 'com.android.application'
    
 android {
     compileSdkVersion 28
     defaultConfig {
         applicationId "demo.tensorflow.org.customvision_sample"
         minSdkVersion 28
         targetSdkVersion 28
         versionCode 1
         versionName "1.0"
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
         ndk {
             abiFilters "armeabi-v7a", "arm64-v8a", "x86"
         }
     }
     buildTypes {
         release {
             minifyEnabled false
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         }
     }
     sourceSets {
         main {
             jniLibs.srcDirs = ['libs']
         }
     }
 }
    
 dependencies {
     implementation fileTree(dir: 'libs', include: ['*.jar'])
     androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
         exclude group: 'com.android.support', module: 'support-annotations'
     })
     //noinspection GradleCompatible
     implementation 'com.android.support:appcompat-v7:26.+'
     testImplementation 'junit:junit:4.12'
    
     // To use TensorFlow normal version (non-Lite), uncomment the two lines below and comment out the following two lines
     // Also update MSCognitiveServicesCustomVisionObjectDetector.java
     //implementation 'org.tensorflow:tensorflow-android:+'
     //implementation 'ai.customvision.android:inference-tensorflow-libcpp:+@aar'
     implementation 'org.tensorflow:tensorflow-lite:+'
     implementation 'ai.customvision.android:inference-tensorflow-lite-libcpp:+@aar'
 }

Please give me some advice on how to get the sample app to work.

azure-custom-vision
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@Aoki-4614

Hello,

Thanks for reaching out to us, I am checking internally about this sample to see what's the problem.

Thanks,
Yutong

0 Votes 0 ·

Did you find any solution ?
I'm also facing the same problem.

0 Votes 0 ·

0 Answers