I succesfully converted and loaded efficientdet model feature vector from https://tfhub.dev/tensorflow/efficientdet/lite0/feature-vector/1 finetuned using approach from https://github.com/google/automl/tree/master/efficientdet.
Model correctly works on python (correctly detects objects) and converts using tensorflow==2.12.0 and coremltools==6.3.0 (to both: "mlprogram" and "neuralnetwork" with same result)
mlmodel = ct.convert(
[detect_fn],
inputs=[img_type = ct.ImageType(name='image_arrays', shape=(1, height, width, 3))],
outputs=[ct.TensorType(name="detections")],
source="tensorflow",
convert_to="neuralnetwork")
Within the coreML model is loaded with no errors, it's metadata is correctly parsed, but during prediction following error occurs:
2023-06-05 09:10:56.942952+0200 xxxx[1619:435597] [espresso] [Espresso::handle_ex_plan] exception=Espresso exception: "Invalid state": Stack_nd layer: Invalid shapes of input tensors. status=-5
2023-06-05 09:10:56.943016+0200 xxxx[1619:435597] [coreml] Error computing NN outputs -5
2023-06-05 09:10:56.943088+0200 xxxx[1619:435597] [coreml] Failure in -executePlan:error:.
Unable to classify image.
The VNCoreMLTransform request failed
Error: Vision request failed with error "Error Domain=com.apple.vis Code=3 "The VNCoreMLTransform request failed" UserInfo={NSLocalizedDescription=The VNCoreMLTransform request failed, NSUnderlyingError=0x2801267f0 {Error Domain=com.apple.CoreML Code=0 "Error computing NN outputs." UserInfo={NSLocalizedDescription=Error computing NN outputs.}}}"
2023-06-05 09:10:56.991190+0200 xxxx[1619:435607] [espresso] [Espresso::handle_ex_plan] exception=Espresso exception: "Invalid state": Stack_nd layer: Invalid shapes of input tensors. status=-5
2023-06-05 09:10:56.991256+0200 xxxx[1619:435607] [coreml] Error computing NN outputs -5
2023-06-05 09:10:56.991285+0200 xxxx[1619:435607] [coreml] Failure in -executePlan:error:.
Unable to classify image.
The VNCoreMLTransform request failed
Input shape ('image_arrays' layer) is (1, 320, 320, 3) - image type Output shape ('detections' layer) is (1, 100, 7) - containing 100 rows with bounding box coords, class_id, score, and another variable, altogether 7 floats)
Relevant part of the network according to the error message "... Stack_nd layer: ..." might be as presented below:
Has anyone noticed similar error or was able to successfully run this model within coreML? Could anyone verify/confirm whether error is a root cause and know how to fix that?
Tested on:
- MacOS (Dev device: Intel MacBook Pro 16, macOS 13.3
Xcode: 14.3)
- mobile device (Deployment target: iOS 15.6)
Test device: iPhone 13 Pro Max, iOS 16.5