Ask Your Question
0

DNN Low accuracy on TensorFlow MobileNet model

asked 2018-07-18 08:53:23 -0600

eithne gravatar image

I followed this OpenCV wiki guide to perform image object detection on the SSD MobileNet v1 COCO 2017-11-17 model. I've tested with OpenCV 3.4.1 and 3.4.2, TensorFlow 1.9.0, and Python 3.6.5.

The first block of python code runs the model using TensorFlow's API, and only uses OpenCV to display the resulting frame and draw boxes around the detected regions. I slightly modified it to use my webcam instead of a static image, and it works perfectly and detects objects in the scene as expected.

The second block of python code runs the model using OpenCV's DNN API. I wasn't able to get it to run due to an error "Const input blob for weights not found in function getConstBlob", so instead I used this C++ demo from the OpenCV samples, which also uses the webcam.

The issue is: using the OpenCV DNN API, objects in the scene are detected, but much fewer objects are correctly determined, and the ones that are have lower confidence. For example, in a near identical image, TensorFlow identified me with 79% confidence, and a wireless mouse I was holding with 58% confidence, while OpenCV's DNN module identified me with 38% and didn't see the mouse at all.

This is despite using the same model with both. I tried fiddling with all the parameters passed to blobFromImage, but nothing I tried made it as good as using TensorFlow's API. Is this simply a deficiency in OpenCV's DNN module, or am I doing something wrong?

Thank you!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-07-18 12:12:25 -0600

dkurt gravatar image

@eithne,

I tried fiddling with all the parameters passed to blobFromImage, but nothing I tried made it as good as using TensorFlow's API.

There is a table with one and only preprocessing parameters: scale factor 0.00784, mean subtraction 127.5 127.5 127.5and resizing to 300x300.

Have you tried to use OpenCV's sample applications? object_detection.cpp, object_detection.py

edit flag offensive delete link more

Comments

Somehow I missed that table. Thank you! And yes, object_detection.cpp was the "C++ demo" I had linked to in my question.

eithne gravatar imageeithne ( 2018-07-18 15:12:33 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-07-18 08:53:23 -0600

Seen: 1,252 times

Last updated: Jul 18 '18