Skip to content

output name getting via getUnconnectedOutLayersNames is different from description of OpenVINO model #20380

@AvenSun

Description

@AvenSun
System information (version)
  • OpenCV => OpenCV+OpenVINO Windows package 4.5.2 or 4.5.3
  • Operating System / Platform => Windows 64 Bit
  • Compiler => Visual Studio 2019
  • Python => 3.7.9
Detailed description

output name getting via getUnconnectedOutLayersNames is different from description of OpenVINO model

person-vehicle-bike-detection-2004

face-detection-0206

person-detection-0203

currently found three models, the doc page listed above said it has two outputs boxes and labels

but there's not just two when we try getting output via dnn.getUnconnectedOutLayersNames

then if we pass the output to forward of DNN, error occurred

model person-detection-0203
====OutputNames====
['1095_1096.0', '1312_1313.0', '1529_1530.0', '1746_1747.0', '1963_1964.0', '223
4_2235.0', 'boxes', 'labels']
====OutputNames====
Traceback (most recent call last):
  File "dnn.py", line 58, in <module>
    outs = net.forward(outNames)
cv2.error: [ PARAMETER_MISMATCH ] Failed to set output Blob. Dimensions mismatch
.

if we specify output ['boxes', 'labels'] , same error

model person-detection-0203
====OutputNames====
['1095_1096.0', '1312_1313.0', '1529_1530.0', '1746_1747.0', '1963_1964.0', '223
4_2235.0', 'boxes', 'labels']
====OutputNames====
Traceback (most recent call last):
  File "dnn.py", line 58, in <module>
    outs = net.forward(outNames)
cv2.error: [ PARAMETER_MISMATCH ] Failed to set output Blob. Dimensions mismatch
.

if we specify output ['boxes'] , there's no error, but getting different result when running multi times
the input image is the same one

Steps to reproduce
import cv2

# OpenCV+OpenVINO Windows package
# https://github.com/opencv/opencv/wiki/Intel's-Deep-Learning-Inference-Engine-backend#opencvopenvino-windows-package-community-version

model_root = '/intel'

# https://docs.openvinotoolkit.org/latest/omz_models_model_person_vehicle_bike_detection_2003.html
prefix = 'person-vehicle-bike-detection-2004'
size = (448,256)

# https://docs.openvinotoolkit.org/latest/omz_models_model_face_detection_0206.html
prefix = 'face-detection-0206'
size = (640,640)

# https://docs.openvinotoolkit.org/latest/omz_models_model_person_detection_0203.html
prefix = 'person-detection-0203'
size = (864,480)

print('model {}'.format(prefix))
net = cv2.dnn.Net_readFromModelOptimizer(
    model_root + '/{}/FP32/{}.xml'.format(prefix,prefix),
    model_root+ '/{}/FP32/{}.bin'.format(prefix,prefix))
net.setPreferableBackend(cv2.dnn.DNN_BACKEND_INFERENCE_ENGINE)
net.setPreferableTarget(cv2.dnn.DNN_TARGET_CPU)

frame = cv2.imread('./test.jpg')
blob = cv2.dnn.blobFromImage(frame, 1.0, size, swapRB=False, crop=False)

outNames = net.getUnconnectedOutLayersNames()
print('====OutputNames====')
print(outNames)
print('====OutputNames====')

# outNames = []
# outNames.append("boxes")
# outNames.append("labels")

net.setInput(blob)
outs = net.forward(outNames)

print('====OriginalResult====')
print(outs[0][0])
print('====OriginalResult====')

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions