1

My full tech stack is:

  • GCP ML Vision.
  • Exported Model to tflite format (from the same GCP console).
  • XCode for iOS development
  • iPhone 11 pro

I am trying to use a Custom Object detector using MLKit and one model trained in GCP AutoML Vision.
I created the model and exported as tflite file, but when trying to do objectDetector processImage:visionImage, I always get the error:
Error Domain=com.google.visionkit.pipeline.error Code=3 "Pipeline failed to fully start: CalculatorGraph::Run() failed in Run: Calculator::Open() for node "BoxClassifierCalculator" failed: #vk Unexpected number of dimensions for output index 0: got 3D, expected either 2D (BxN with B=1) or 4D (BxHxWxN with B=1, W=1, H=1)." UserInfo={com.google.visionkit.status=<MLKITvk_VNKStatusWrapper: 0x280841270>, NSLocalizedDescription=Pipeline failed to fully start: CalculatorGraph::Run() failed in Run: Calculator::Open() for node "BoxClassifierCalculator" failed: #vk Unexpected number of dimensions for output index 0: got 3D, expected either 2D (BxN with B=1) or 4D (BxHxWxN with B=1, W=1, H=1).}.
I have downloaded the mlkit examples from https://github.com/googlesamples/mlkitand there is something similar in the vision project, (to detect birds) when I try to replace my own tflite file, it breaks in the exact same way as in my own project.
I presume the tflite is created in a very different way as MLVision does.
Any insight? (Sorry if this is so obvious, but I'm pretty new to TensorFlow and MLVision) Thanks in advance

1 Answers1

1

The issue is exactly as what the error message says: got 3D, expected either 2D (BxN with B=1) or 4D (BxHxWxN with B=1, W=1, H=1). That means your model is not compatible with ML Kit, as its tensor has incorrect dimension. The model compatibility requirements are specified here.

Dong Chen
  • 829
  • 4
  • 7
  • Thank you very much for your help on this, in short, any model trained in MLVision will work with the default MLKit SDK, I have been able to read it with a class using TensorFlowObjC library though, quite complicated for beginners like me, but I think I finally solve it. – Victor H. Velazco Hernandez Jun 02 '22 at 03:40