Hello everyone, thanks for all the help you gave me so far. If this problem is solved, this is probably my last question for a few months :)
I recently posted a problem that I had while running a tensorflow CNN using OpenCV, and I managed to make it run using the master branch thanks to dkurt. Now I need to make it work :P
The problem is that the master branch is giving numerical results very different from the version 3.3.0, which is the one giving results similar to tensorflow.
This is the code that I'm using: https://pastebin.com/xbcjru1m
This is an all-in-one implementation of our work that I intend to release soon (still not finished): https://arxiv.org/pdf/1710.07662.pdf
I added the tensorflow models and the image I use as input for the numerical examples below here: https://drive.google.com/open?id=1Vj2holDc5LZyKZCCFl7cEdrZmXjVbCXZ
This is the output I get for version 3.3.0:
10.6368 -9.62331
57.1009,15.0345 49.1725,9.35289 41.2432,5.27753 33.1887,5.14996 26.9975,9.64316 24.1903,16.5573 23.3795,24.8945 24.703,32.8969 27.5521,40.898 30.6558,48.6363 33.6907,55.7202 36.9645,62.886 40.9232,69.6389 45.1071,76.0207 49.5653,82.1074 54.7589,87.2224 60.7443,91.2243 66.9655,92.4323 72.133,90.0989 75.1398,85.7536 60.6781,39.0338 56.7915,30.7083 52.2409,23.2375 46.7008,17.6615 40.4759,14.3339 33.8519,13.7421 29.0189,17.1593 28.1586,23.7111 28.9887,30.8795 31.2067,37.9041 33.5278,45.1232 36.3979,51.7835 39.2748,58.379 43.4146,64.2663 48.7502,69.3365 63.5614,42.5317 61.7706,48.4019 62.3384,56.5137 66.4177,61.6003 67.7452,66.2748 63.3672,64.6332 58.8021,60.4604 53.0287,59.6051 48.3177,56.8109 46.271,51.6537 46.3323,46.0759 47.5009,41.3566 49.7026,37.6776 52.3834,34.809 55.5715,32.9558 37.0859,45.7425 36.3689,38.8235 36.3324,31.8219 36.5529,24.9157 37.313,18.4695
OpenCV Error: Assertion failed (srcMat.dims == 2 && srcMat.cols == weights.cols && dstMat.rows == srcMat.rows && dstMat.cols == weights.rows && srcMat.type() == weights.type() && weights.type() == dstMat.type() && srcMat.type() == CV_32F && (biasMat.empty() || (biasMat.type() == srcMat.type() && biasMat.isContinuous() && (int)biasMat.total() == dstMat.cols))) in run, file /home/mauricio/Libraries/OpenCV3.3/opencv-3.3.0/modules/dnn/src/layers/fully_connected_layer.cpp, line 132
terminate called after throwing an instance of 'cv::Exception'
what(): /home/mauricio/Libraries/OpenCV3.3/opencv-3.3.0/modules/dnn/src/layers/fully_connected_layer.cpp:132: error: (-215) srcMat.dims == 2 && srcMat.cols == weights.cols && dstMat.rows == srcMat.rows && dstMat.cols == weights.rows && srcMat.type() == weights.type() && weights.type() == dstMat.type() && srcMat.type() == CV_32F && (biasMat.empty() || (biasMat.type() == srcMat.type() && biasMat.isContinuous() && (int)biasMat.total() == dstMat.cols)) in function run
As I said, version 3.3.0 does not work for the last model, so it crashes. But the numerical output for the first two models is accurate in comparison to the output from tensorflow. Below you can see the output for the master branch:
1.05193 -0.755713
61.1416,25.3116 56.3162,18.6798 50.9037,14.0388 45.0847,12.3341 40.1558,14.6271 37.1991,19.3822 35.4203,25.3895 34.8478,31.2775 34.6743,37.8194 35.485,43.9626 36.5118,49.7147 37.9703,55.2384 39.2245,61.155 40.4719,66.8579 42.4962,73.0747 45.0312,78.3796 48.5122,82.8163 52.1999,86.2265 56.8659,87.4667 61.3056,86.8054 58.3643,43.2236 57.3804,36.1717 55.6893,29.0762 52.7211,23.7635 49.0313,20.659 44.0795,19.0188 39.5918,22.3106 37.4713,28.1936 36.6186,33.8465 37.0455,39.6164 37.3868,44.7326 37.8458,50.3742 38.8872,55.4452 40.6549,60.7395 43.3369,65.4015 59.7699,48.0224 57.1961,52.6742 56.7634,59.0415 58.9749,63.7826 58.8748,67.5619 56.0967,65.4724 53.4999,61.3504 49.8255,59.528 46.2595,56.3114 45.3176,51.4922 46.1125,46.6622 47.9935,43.434 50.2412,41.141 53.1519,39.8385 56.0578,39.5967 41.3667,42.7495 42.4297,37.3743 44.2865,32.3982 46.2206,27.8661 48.4139,23.4983
1 512
Output images for the version 3.3.0:
Output images for master branch:
As you may see, the code is working for the version 3.3.0, but it cannot use the last CNN. The master branch is able to run all CNNs, but does not give the correct values. Any ideas?