Objects detected as multiple dots while using custom tensorflow model in OpenCV dnn [closed]
I am using Ubuntu 16.04, built Opencv 3.4.0 from source using master for python 2.7 and 3.5 today (expecting the PR's pushed for tensorflow multibox anchors dnn issues)
I tried to replicate frozen_inference_graph.pb & textgraph
On running the sample provided as project.py
import numpy as np
import cv2 as cv
cvNet = cv.dnn.readNetFromTensorflow('frozen_inference_graph.pb', 'ssd_mobilenet_v1_coco_hat.pbtxt')
img = cv.imread('image4.jpg')
cvNet.setInput(cv.dnn.blobFromImage(img, 1.0/127.5, (300, 300), (127.5, 127.5, 127.5), swapRB=True, crop=False))
cvOut = cvNet.forward()
for detection in cvOut[0,0,:,:]:
score = float(detection[2])
if score > 0.5:
left = detection[3] * img.shape[1]
top = detection[4] * img.shape[0]
right = detection[5] * img.shape[1]
bottom = detection[6] * img.shape[0]
cv.rectangle(img, (int(left), int(top)), (int(right), int(bottom)), (0, 255, 0))
cv.imshow('img', img)
cv.waitKey(0)
tf_importer.cpp and prior_box_layer.cpp files of OpenCV master sourceare shared here:
https://drive.google.com/open?id=1YgS...
Output is with detections having couple of random green color dots as below, instead of rectangular bounding boxes
Any fix for this would be very much helpful
@krishnapra, Please try to run a script tf_text_graph_ssd.pyas described in wiki page https://github.com/opencv/opencv/wiki... to get a text graph. Then pass it as a second argument of
readNetFromTensorflow
. The first argument will befrozen_inference_graph.pb
.@dkurt I couldn't get desired result when used text graph generated from tf_text_graph_ssd.py. Result was having no bounding boxes at detections, not even dots. I am not sure why this is happening
I tried replacing prior_box_layer.cpp & tf_importer.cpp in my latest opencv 3.4.0 folder with files at https://github.com/opencv/opencv/pull... and re-compiled opencv. Now i am able to get proper bounding boxes for the code mentioned in my post.
@krishnapra I encountered the similar question
I think there are bugs in tf_text_graph_ssd.py