YOLOv3-CoreML icon indicating copy to clipboard operation
YOLOv3-CoreML copied to clipboard

EXC_BAD_ACCESS crash when running app with YOLOv3-SPP model trained on custom data.

Open fellowProgrammer opened this issue 4 years ago • 5 comments

I trained a YOLOv3-SPP model using custom data, I have 3 classes. I then converted it to a Keras .h5 file and then converted it to a CoreML. I ended up with a CoreML model whose Prediction section looks like this.

Screen Shot 2020-01-08 at 6 09 29 PM

I tried to use the app by adding the model to Xcode and changing the numClasses variable to 3, yet I still get this crash.

Screen Shot 2020-01-08 at 6 13 00 PM

I am quite new to the CoreML world so I don't have a good grasp on what info the MLMultiArrays hold and how to access it etc. What can I do to solve this crash? Is there something wrong with my model or is it just the app?

fellowProgrammer avatar Jan 09 '20 00:01 fellowProgrammer

Any updates? Have the same issue

andriikrupka avatar Mar 24 '20 15:03 andriikrupka

Me too. Are there any solutions????

tj16kimura avatar Oct 21 '20 13:10 tj16kimura

I solved this problem by replacing

    for i in 0..<3 {  
            featurePointer = UnsafeMutablePointer<Double>(OpaquePointer(features[i].dataPointer))
            channelStride = features[i].strides[0].intValue
            yStride = features[i].strides[1].intValue
            xStride = features[i].strides[2].intValue

to

    for i in 0..<3 {  
            featurePointer = UnsafeMutablePointer<Double>(OpaquePointer(features[i].dataPointer))
            channelStride = features[i].strides[2].intValue
            yStride = features[i].strides[3].intValue
            xStride = features[i].strides[4].intValue

thanks

tj16kimura avatar Oct 28 '20 23:10 tj16kimura

@tj16kimura How did you find that? It's not so obvious

andriikrupka avatar Oct 29 '20 12:10 andriikrupka

@tj16kimura How did you find that? It's not so obvious

I checked the shape of features and found it was not correct. I think it's because of Xcode's version.

sorry for my cheap English :<

tj16kimura avatar Oct 29 '20 12:10 tj16kimura