Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Results of opencv dnn looks weird when using the tensorflow model(faster rcnn) to detect the object

Link of the model zoo--https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md Link of the model zip--http://download.tensorflow.org/models/object_detection/faster_rcnn_inception_resnet_v2_atrous_oid_2018_01_28.tar.gz

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

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()
  1. The results

Input image image description

results image description

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

Results of opencv dnn looks weird when using the tensorflow model(faster rcnn) to detect the object

  • Link of the model zoo--https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md
    • Link of the model zip--http://download.tensorflow.org/models/object_detection/faster_rcnn_inception_resnet_v2_atrous_oid_2018_01_28.tar.gz

      zip(using faster_rcnn_inception_resnet_v2_atrous_oidv2)--http://download.tensorflow.org/models/object_detection/faster_rcnn_inception_resnet_v2_atrous_oid_2018_01_28.tar.gz

    • OS : win 10 64 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

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()
  1. The results

Input image image description

results image description

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

Results of opencv dnn looks weird when using the tensorflow model(faster rcnn) to detect the object

  • Link of the model zoo--https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md
    • Link of the model zip(using faster_rcnn_inception_resnet_v2_atrous_oidv2)--http://download.tensorflow.org/models/object_detection/faster_rcnn_inception_resnet_v2_atrous_oid_2018_01_28.tar.gz
    • 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()
  1. The results

Input image image description

results image description

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

Results of opencv dnn looks weird when using the tensorflow model(faster rcnn) to detect the object

  • Link of the model zoo--https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md
    • Link of the model zip(using faster_rcnn_inception_resnet_v2_atrous_oidv2)--http://download.tensorflow.org/models/object_detection/faster_rcnn_inception_resnet_v2_atrous_oid_2018_01_28.tar.gz
    • 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()
  1. The results

Input image image description

results image description

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.

image description

Results of opencv dnn looks weird when using the tensorflow model(faster rcnn) to detect the object

  • Link of the model zoo-- - Link of the model zoo--https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md

    • - Link of the model zip(using faster_rcnn_inception_resnet_v2_atrous_oidv2)--http://download.tensorflow.org/models/object_detection/faster_rcnn_inception_resnet_v2_atrous_oid_2018_01_28.tar.gz
    • faster_rcnn_inception_resnet_v2_atrous_oidv2)--http://download.tensorflow.org/models/object_detection/faster_rcnn_inception_resnet_v2_atrous_oid_2018_01_28.tar.gz - OS : win 10 64
    • 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()
  1. The results

Input image image description

results image description

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.

image description

Results of opencv dnn looks weird when using the tensorflow model(faster rcnn) to detect the object

Link of the model zoo-- - Link of the download model zoo--https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md - Link of the model zip(using faster_rcnn_inception_resnet_v2_atrous_oidv2)--http://download.tensorflow.org/models/object_detection/faster_rcnn_inception_resnet_v2_atrous_oid_2018_01_28.tar.gz - zip

  • OS : win 10 64 - 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()
  1. The results

Input image image description

results image description

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.

image description