I have trained a CNN in Matlab 2019b that does a binary classification. When this CNN was tested in a test dataset it was getting about 95% accuracy. I used the exportONNXNetwork function so that I can implement my CNN in Tensorflow, Keras. This is the code I am using to use the ONNX file in keras:
import onnx
from onnx_tf.backend import prepare
import numpy as np
from numpy import array
from IPython.display import display
from PIL import Image
onnx_model = onnx.load("model.onnx")
tf_rep = prepare(onnx_model)
img = Image.open("image.jpg").resize((224,224))
img = array(img).reshape(1,3,224,224)
img = img.astype(np.uint8)
classification = tf_rep.run(img)
print(classification)
When this python code was tested on the same test dataset it was classifying almost everything as class 0 with a few cases of class 1. I am not sure why this is happening.