MATLAB Answers

Matlab CNN model to ONNX - Inference Image Classification Results

조회 수: 7(최근 30일)
Andrea Daou
Andrea Daou 2021년 8월 3일
댓글: Andrea Daou 2021년 8월 4일
Hello all,
I used 'exportONNXNetwork(net,filename)' function to export a fine-tuned CNN .mat model (mobilenet pretrained and fine-tuned on new dataset) to .onnx model.
When using the .onnx model in image classification inference I am getting wrong classification results. I compared the results that I am getting from Matlab inference with ONNX inference, it is not the same although the model was well exported and I checked some of the weights and biases of the network.
Does I need to make any additional conversion ? Is there any difference between the two models (I think the input is of shape 3*224*224 in ONNX instead of 224*224*3 in Matlab) ?
Thank you in advance. Appreciate your help!

답변(1개)

cui
cui 2021년 8월 4일
yes , you are correct, in onnnx file the input is of shape BatchSize*3*224*224 instead of 224*224*3*BatchSize in Matlab,
  댓글 수: 1
Andrea Daou
Andrea Daou 2021년 8월 4일
I used a step to correct the image shape because I am not getting any error when doing the inference with the .onnx model but the prediction and all the classes probabilities are way different from the inference done in Matlab that gives correct predictions.
I tried to make sure that the network is correctly passing from .mat to .onnx by repassing from the .oonx model to .mat and running the inference with the new .mat model and I got right predictions.
So I am not getting where's the problem :(

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by