PersonalImageClassifier returns Error -1 even after ClassifierReady fires

Hello everyone,

I am facing an issue with the PersonalImageClassifier extension and would appreciate your guidance.

What I am trying to do

I built a simple image-classification app using PersonalImageClassifier:

  1. User clicks a button
  2. Camera takes a picture
  3. The captured image is displayed in an Image component
  4. The image is sent to the PersonalImageClassifier for classification
  5. The predicted label should be displayed in a Label component

Blocks logic (high level)

I am using the following events:

  • When Button.Click
    → Call Camera.TakePicture
  • When Camera.AfterPicture(image)
    → Set Image.Picture to image
    → Call classifier (using the available method for PersonalImageClassifier)
  • When PersonalImageClassifier.ClassifierReady
    → This event fires successfully
  • When PersonalImageClassifier.Error(errorCode)
    → This fires with errorCode = -1
  • When PersonalImageClassifier.GotResult(result)
    → This event never fires

Important observations

  • ClassifierReady does fire, so the model seems to load

  • Immediately after calling the classification method, Error fires with -1

  • The model was trained using the PIC web page and downloaded as a .mdl file

  • I am testing using the MIT AI Companion

  • A WebViewer component is present and set in the classifier properties

My question

  1. What does Error -1 specifically indicate in this context?
  2. Is this related to:
  • .mdl model compatibility?
  • WebViewer / Android WebView limitations?
  • Companion vs APK behavior?
  1. Is there a known limitation or workaround for this issue?

Attachments

I have attached:

  • Screenshots of the Blocks
  • Screenshots of the UI
  • Screenshots of PersonalImageClassifier and WebViewer properties

Thank you very much for your time and support.
Any clarification or confirmation would be greatly appreciated.

Best regards,
Jalal




looking-searching

1 Like

Thanks a lot for notifying me :blush:
Just added them now!

What is the value of the image variable in AfterPicture?

Thank you very much for your response,

The image parameter value is:

file:///storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/Pictures/app_inventor_1766000783875.jpg

I tested classification using a Media (uploaded) image instead of the Camera. The same Error -1 occurs immediately after calling ClassifyImage.

I tried to test the App using a built APK, however it took long time and did not install on my device.

Best Regards

Thanks for all of you who responded to the topic.
I have redone the project using TMIC (Teachable Machine Image Classifier) extension, and it worked fine.
Best regards

The Original one is also working now...ChatGPT was the cause! I now made sure that the webviewer is using the camera and removed its homeURL.