kylecorry31 / ML4K-AI-Extension

Use machine learning in AppInventor, with easy training using text, images, or numbers through the Machine Learning for Kids website.
MIT License
20 stars 15 forks source link

Image classification fails calling .ClassifyImage #20

Closed gsebastia closed 5 years ago

gsebastia commented 5 years ago

Hello. I am trying with my first app with MI4K but I've never got a version that gives me back an image classification. I have tried different ways to send the image, but now the application fails. I don't know if the problem is the key, the way i send the image...

To simplify my tests, I leaved my project and I took the example CirclesAndRectangles, I created a project in machine learning for kids, I generated the model, and I copied the key from the url:

https://machinelearningforkids.co.uk/api/appinventor/b27f9f70-1694-11e9-b8e9-6f11f826e259e313c6de-ffb5-492e-8340-2390b8ae4ee4/extension

but when executing it on my phone it fails (see error message below) just like my project ... what am I doing wrong?

Thank you very much!

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/gson/JsonParser; at com.kylecorry.ml4k.ML4K$Classification.fromJson(ML4K.java:426) at com.kylecorry.ml4k.ML4K$Classification.access$400(ML4K.java:414) at com.kylecorry.ml4k.ML4K$1.run(ML4K.java:118) at java.lang.Thread.run(Thread.java:760) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.gson.JsonParser" on path: DexPathList[[zip file "/data/app/appinventor.ai_gsebastia.eFAP_1_c-2/base.apk"],nativeLibraryDirectories=[/data/app/appinventor.ai_gsebastia.eFAP_1_c-2/lib/arm64, /system/lib64, /vendor/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:74) at java.lang.ClassLoader.loadClass(ClassLoader.java:380) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) ... 4 more

many thanks

kylecorry31 commented 5 years ago

Hello, so this looks like an issue where AppInventor is not sending over the required libraries. I don't know how many other people this is affecting, so I have removed the need for that library. The latest version should work now.

gsebastia commented 5 years ago

Hello Kyle, now it works!

I'm not sure if solution was new version, or problem was that I made so many tests and so many apps with different mi4k projects that my phone (two phones, actually) had charged in memory an incorrect version of extension. In case it is usefull, I tell you about the process

I have tested an app make by Dale Lane with my key, and at first It didn't work in my phones. I have installed this app in a third phone (with no other app with MI4K installed) ... and it worked!

I had to uninstall from my phones all different apps and versions I generated with app inventor and ML4K extension, I've reboot my phone and installed only one version (new extension?)....and it runned!

This is a project of my son and some friends, and I was helping them to solve the problem.

Thank you very much!

bh26 commented 5 years ago

I am trying to solve a similar issue but I cannot get it to work. I am trying the example CirclesAndRectangles.aia Actually I did everything that was needed on ML4K site, and got the URL for the extension. I understand from another issue that the API Key was included in the extension. Anyway I added the API key in the Screen.Initialize block But whatever I do I get "Bad response by server:404" I did it on 2 different phones once with the companion and once with .apk, all with the same result. What could I have done wrong? Thanks