- 'zerocenter' — Subtract the average image specified by the AverageImage property. The trainNetwork function automatically computes the average image at training time.
My ONNX network doesn't work when loaded in my Java application
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Luigi Treccozzi
il 10 Lug 2019
Risposto: Luigi Treccozzi
il 11 Lug 2019
Hi guys! I'm developping a Java application that uses a CNN, precisely an AlexNet. I followed these tutorials https://it.mathworks.com/matlabcentral/fileexchange/62990-deep-learning-tutorial-series , https://it.mathworks.com/help/deeplearning/ref/alexnet.html and https://it.mathworks.com/help/deeplearning/ref/trainnetwork.html . Now a weird thing occurs: I generated the network with a high accuracy (96.5% on a dataset "never seen before", that comes from the environment that the network is thought to work on). Next, I loaded the model in my Java application, using the OpenCV method readNetFromONNX ( https://docs.opencv.org/master/javadoc/org/opencv/dnn/Dnn.html ) but the network completely misclassifies. It's not a wrong coding of the classes, it simply "randomly" classifies. The thing is that, if I generate (with the same code, and same dataset) a network with a lower accuracy, maybe with a bad choice of training parameters (I mean about 90%), it works fine when loaded (by "fine" I mean at 90%, obviously). I thought it was overtraining, and, in fact, I trained the network with the test set getting an accuracy of (surprise surprise) 99.89%, but when I load it on my Java application (where, some inputs coming from the test set are given) the same thing occurs, it completely missclassifies everything that come as input. It's like Java doesn't accept the network that has a high accuracy.
0 Commenti
Risposta accettata
Gabija Marsalkaite
il 10 Lug 2019
Hi Luigi,
One possibility is differences in normalisation of data - Alexnet has zero-center normalisation in the first layer in MATLAB but it may work slightly differently when used with Java. According to documentation:
I expect it should work if you preprocess images this way. Let me know if that solves your issue.
0 Commenti
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Image Data Workflows in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!