Different detection result between opencv and tensorflow api

asked 2019-01-21 21:16:19 -0600

alisa_Li gravatar image

updated 2019-01-22 01:27:13 -0600

  • OpenCV =3.4.3(C++)
  • Operating System / Platform = Windows10 64 Bit/Ubuntu 16.04
  • Compiler = Visual Studio 2017
  • tensorflow = 1.8.0

I have trained SSD_mobilenet_v1 model in tensorflow(num_classes:3), and i follow this web guide use tf_text_graph_ssd.py

and generate a config file,but the result of opencv is different from the tensorflow api, tensorflow detection result is accurate but opencv is not this is my config filelink and some parameters of input

net.setInput(blobFromImage(image, 2./255, Size(300, 300), Scalar(127.5, 127.5, 127.5), true,true));

In fact, I use config file( opencv provideconfig) and get the better result, but it is not like tensorflow api result

edit retag flag offensive close merge delete

Comments

can you check the params again ? imho, for the inception tf nmodel you need swapRB=false, and a scale of 1./255

berak gravatar imageberak ( 2019-01-22 01:35:14 -0600 )edit
2

@berak, It also depends on version of OpenCV. The latest one includes preprocessing mean subtraction and scaling into TensorFlow graph. @alisa_Li, Please use tf_text_graph_ssd.py script from the same version of OpenCV (3.4.3).

dkurt gravatar imagedkurt ( 2019-01-22 02:27:16 -0600 )edit

@berak my parameters come from herelink

alisa_Li gravatar imagealisa_Li ( 2019-01-22 04:59:29 -0600 )edit

@dkurt thank you so much:) ,now the detection result is well, I didn't think about the problem of script version

alisa_Li gravatar imagealisa_Li ( 2019-01-22 05:04:41 -0600 )edit