Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.
6454 Discussions

openvino.inference_engine.ie_api.IENetwork' object has no attribute 'inputs'

jeremyang012
Beginner
1,651 Views

I am currently using this 'person detector' python coding and am trying to implement it with object algorithms algorithm. I have my XML file prepared and have it running. However, there is this error shown below:

 

for blob_name in net.inputs:
AttributeError: 'openvino.inference_engine.ie_api.IENetwork' object has no attribute 'inputs'

 

Can anyone help me identify what is the error ? Here is the full coding below:

 

import sys
import os
import cv2
import time
import numpy as np
from openvino.inference_engine import IECore, IENetwork, Blob

ie = IECore()

model_xml = "Web.xml"
model_bin = os.path.splitext(model_xml)[0] + ".bin"
device = 'CPU'

net = ie.read_network(model=model_xml, weights=model_bin)
net.serialize(model_xml, model_bin)
img_info_input_blob = None
feed_dict = {}

for blob_name in net.inputs:
if len(net.inputs[blob_name].input_data.shape) == 4:
input_blob = blob_name
elif len(net.inputs[blob_name].input_data.shape) == 2:
img_info_input_blob = blob_name
else:
raise RuntimeError("Unsupported {}D input layer '{}'. Only 2D and 4D input layers are supported"
.format(len(net.inputs[blob_name].input_data.shape), blob_name))
assert len(net.outputs) == 1, "Demo supports only single output topologies"
out_blob = next(iter(net.outputs))
exec_net = ie.load_network(network=net, num_requests=2, device_name=device)

# Read and pre-process input image
n, c, h, w = net.inputs([input_blob].input_data.shape)

if img_info_input_blob:
feed_dict[img_info_input_blob] = [h, w, 1]
cur_request_id = 0

cap = cv2.VideoCapture(0)
while cap.isOpened():
ret, frame = cap.read()
if ret:
frame_h, frame_w = frame.shape[:2]
inf_start = time.time()
in_frame = cv2.resize(frame, (w, h))
in_frame = in_frame.transpose((2, 0, 1)) # Change data layout from HWC to CHW
in_frame = in_frame.reshape((n, c, h, w))

feed_dict[input_blob] = in_frame
exec_net.start_async(request_id=cur_request_id, inputs=feed_dict)
if exec_net.requests[cur_request_id].wait(-1) == 0:
inf_end = time.time()
det_time = inf_end - inf_start
res = exec_net.requests[cur_request_id].outputs[out_blob]

# Draw performance stats
inf_time_message = "Fps: {:.2f}".format(det_time * 1000)
cv2.rectangle(frame, (4, 3), (95, 20), (0, 0, 0), -1)
cv2.putText(frame, inf_time_message, (5, 15), cv2.FONT_HERSHEY_COMPLEX, 0.5, (0, 255, 255), 1)
cv2.imshow("Detections", frame)
key = cv2.waitKey(1)
if key == 27:
break
cv2.destroyAllWindows()

 

 

0 Kudos
2 Replies
IntelSupport
Community Manager
1,624 Views

Hi Jeremyang012,

 

Thanks for reaching out.

 

For your information, ie_api.IENetwork.inputs property is deprecated starting on OpenVINO 2020.4. For the latest OpenVINO (2022.1), please use the input_info property to get the map of the inputs. You may refer to this openvino.inference_engine.IENetwork documentation.

 

For now, I am able to solve the error by changing the input property. However, I received AssertionError as below:

jeremy.JPG

 

I am using person-detection-0106 and this error might due to the unsupported model with the demo. You can test with your model and get back to me with the result.

 

 

Regards,

Aznie

 

0 Kudos
IntelSupport
Community Manager
1,592 Views

Hi Jeremyang012,


This thread will no longer be monitored since we have provided a solution. If you need any additional information from Intel, please submit a new question.



Regards,

Aznie


0 Kudos
Reply