Results of opencv dnn looks weird when using the tensorflow model(faster rcnn) to detect the object
Link of the model zoo-- download model zip
- OS : win 10 64
- opencv version : 4.1.2, installed by anaconda
Using the opencv dnn module to perform object detection by the tensorflow model. But the results seems weird.
Steps to reproduce
1 : Generate the config file by tf_text_graph_faster_rcnn.py
python tf_text_graph_faster_rcnn.py --input frozen_inference_graph.pb --config pipeline.config --output faster_rcnn_inception_resnet_v2_atrous_oid.pbtxt
frozen_inference_graph.pb and pipeline.config are the files after unzip
2 : detect object by the example codes
import cv2 as cv
cvNet = cv.dnn.readNetFromTensorflow('tensorflow/faster_rcnn_inception_resnet_v2_atrous_oid.pb', 'tensorflow/faster_rcnn_inception_resnet_v2_atrous_oid.pbtxt')
img = cv.imread('traffic_jam.jpg')
rows = img.shape[0]
cols = img.shape[1]
cvNet.setInput(cv.dnn.blobFromImage(img, size=(300, 300), swapRB=True, crop=False))
cvOut = cvNet.forward()
for detection in cvOut[0,0,:,:]:
score = float(detection[2])
if score > 0.1:
left = detection[3] * cols
top = detection[4] * rows
right = detection[5] * cols
bottom = detection[6] * rows
cv.rectangle(img, (int(left), int(top)), (int(right), int(bottom)), (23, 230, 210), thickness=2)
cv.imshow('img', img)
cv.waitKey()
- The results
Input image
results
Almost every cars cannot detected by this network, I have tried to change the size of image, but results become worse in this case. How should I fix this issue?Thanks
Edit : If I use the tensorflow api(1.15) to do the object detection(example on this page)the results seems much better, although there are many vehicles cannot detected.
Does this solved your problem tensorflow model?
This may not solved problem.