Skip to content

Commit 2a94f0f

Browse files
Merge pull request #1524 from openvinotoolkit/fix/kgeneral/rm_cpu_layer_check
fix #38545 remove CPU network layer check for py demos
2 parents 366130d + 036edc1 commit 2a94f0f

File tree

9 files changed

+6
-94
lines changed

9 files changed

+6
-94
lines changed

demos/python_demos/asl_recognition_demo/asl_recognition_demo/common.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ def __init__(self, model_path, device, ie_core, num_requests, output_shape=None)
3737
self.net = ie_core.read_network(model_path + ".xml", model_path + ".bin")
3838
assert len(self.net.input_info) == 1, "One input is expected"
3939

40-
supported_layers = ie_core.query_network(self.net, device)
41-
not_supported_layers = [l for l in self.net.layers.keys() if l not in supported_layers]
42-
if len(not_supported_layers) > 0:
43-
raise RuntimeError("Following layers are not supported by the {} plugin:\n {}"
44-
.format(device, ', '.join(not_supported_layers)))
45-
4640
self.exec_net = ie_core.load_network(network=self.net,
4741
device_name=device,
4842
num_requests=num_requests)

demos/python_demos/instance_segmentation_demo/instance_segmentation_demo.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,6 @@ def main():
133133
log.info('Loading network')
134134
net = ie.read_network(args.model, os.path.splitext(args.model)[0] + '.bin')
135135

136-
if 'CPU' in args.device:
137-
supported_layers = ie.query_network(net, 'CPU')
138-
not_supported_layers = [l for l in net.layers.keys() if l not in supported_layers]
139-
if len(not_supported_layers) != 0:
140-
log.error('Following layers are not supported by the plugin for specified device {}:\n {}'.
141-
format(args.device, ', '.join(not_supported_layers)))
142-
log.error("Please try to specify cpu extensions library path in sample's command line parameters using -l "
143-
"or --cpu_extension command line argument")
144-
sys.exit(1)
145-
146136
required_input_keys = {'im_data', 'im_info'}
147137
assert required_input_keys == set(net.input_info), \
148138
'Demo supports only topologies with the following input keys: {}'.format(', '.join(required_input_keys))

demos/python_demos/monodepth_demo/monodepth_demo.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def main():
1717
"-m", "--model", help="Required. Path to an .xml file with a trained model", required=True, type=str)
1818
parser.add_argument(
1919
"-i", "--input", help="Required. Path to a input image file", required=True, type=str)
20-
parser.add_argument("-l", "--cpu_extension",
20+
parser.add_argument("-l", "--cpu_extension",
2121
help="Optional. Required for CPU custom layers. Absolute MKLDNN (CPU)-targeted custom layers. "
2222
"Absolute path to a shared library with the kernels implementations", type=str, default=None)
23-
parser.add_argument("-d", "--device",
23+
parser.add_argument("-d", "--device",
2424
help="Optional. Specify the target device to infer on; CPU, GPU, FPGA, HDDL or MYRIAD is acceptable. "
2525
"Sample will look for a suitable plugin for device specified. Default value is CPU", default="CPU", type=str)
2626

@@ -38,18 +38,6 @@ def main():
3838
log.info("Loading network")
3939
net = ie.read_network(args.model, os.path.splitext(args.model)[0] + ".bin")
4040

41-
if "CPU" in args.device:
42-
supported_layers = ie.query_network(net, "CPU")
43-
not_supported_layers = [
44-
l for l in net.layers.keys() if l not in supported_layers]
45-
46-
if len(not_supported_layers) != 0:
47-
log.error("Following layers are not supported by the plugin for specified device {}:\n {}".
48-
format(args.device, ', '.join(not_supported_layers)))
49-
log.error("Please try to specify a CPU extensions library path in sample's command line parameters "
50-
"using -l or --cpu_extension command line argument")
51-
sys.exit(1)
52-
5341
assert len(net.input_info) == 1, "Sample supports only single input topologies"
5442
assert len(net.outputs) == 1, "Sample supports only single output topologies"
5543

@@ -69,7 +57,7 @@ def main():
6957
log.info("Image is resized from {} to {}".format(
7058
image.shape[:-1], (height, width)))
7159
image = cv2.resize(image, (width, height), cv2.INTER_CUBIC)
72-
60+
7361
# prepare input
7462
image = image.astype(np.float32)
7563
image = image.transpose((2, 0, 1))

demos/python_demos/multi_camera_multi_target_tracking/utils/ie_tools.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,6 @@ def load_ie_model(ie, model_xml, device, plugin_dir, cpu_extension='', num_reqs=
6969
log.info("Loading network")
7070
net = ie.read_network(model_xml, os.path.splitext(model_xml)[0] + ".bin")
7171

72-
if "CPU" in device:
73-
supported_layers = ie.query_network(net, "CPU")
74-
not_supported_layers = [l for l in net.layers.keys() if l not in supported_layers]
75-
if not_supported_layers:
76-
log.error("Following layers are not supported by the plugin for specified device %s:\n %s",
77-
device, ', '.join(not_supported_layers))
78-
log.error("Please try to specify cpu extensions library path in sample's command line parameters using -l "
79-
"or --cpu_extension command line argument")
80-
sys.exit(1)
81-
8272
assert len(net.input_info) == 1 or len(net.input_info) == 2, \
8373
"Supports topologies with only 1 or 2 inputs"
8474
assert len(net.outputs) == 1 or len(net.outputs) == 4 or len(net.outputs) == 5, \

demos/python_demos/object_detection_demo_ssd_async/object_detection_demo_ssd_async.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,6 @@ def main():
111111
log.info("Loading network")
112112
net = ie.read_network(args.model, os.path.splitext(args.model)[0] + ".bin")
113113

114-
if "CPU" in args.device:
115-
supported_layers = ie.query_network(net, "CPU")
116-
not_supported_layers = [l for l in net.layers.keys() if l not in supported_layers]
117-
if len(not_supported_layers) != 0:
118-
log.error("Following layers are not supported by the plugin for specified device {}:\n {}".
119-
format(args.device, ', '.join(not_supported_layers)))
120-
log.error("Please try to specify cpu extensions library path in sample's command line parameters using -l "
121-
"or --cpu_extension command line argument")
122-
sys.exit(1)
123-
124114
img_info_input_blob = None
125115
feed_dict = {}
126116
for blob_name in net.input_info:

demos/python_demos/object_detection_demo_yolov3_async/object_detection_demo_yolov3_async.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -319,20 +319,9 @@ def main():
319319
log.info("Loading network")
320320
net = ie.read_network(args.model, os.path.splitext(args.model)[0] + ".bin")
321321

322-
# ---------------------------------- 3. Load CPU extension for support specific layer ------------------------------
323-
if "CPU" in args.device:
324-
supported_layers = ie.query_network(net, "CPU")
325-
not_supported_layers = [l for l in net.layers.keys() if l not in supported_layers]
326-
if len(not_supported_layers) != 0:
327-
log.error("Following layers are not supported by the plugin for specified device {}:\n {}".
328-
format(args.device, ', '.join(not_supported_layers)))
329-
log.error("Please try to specify cpu extensions library path in sample's command line parameters using -l "
330-
"or --cpu_extension command line argument")
331-
sys.exit(1)
332-
333322
assert len(net.input_info) == 1, "Sample supports only YOLO V3 based single input topologies"
334323

335-
# ---------------------------------------------- 4. Preparing inputs -----------------------------------------------
324+
# ---------------------------------------------- 3. Preparing inputs -----------------------------------------------
336325
log.info("Preparing inputs")
337326
input_blob = next(iter(net.input_info))
338327

@@ -356,7 +345,7 @@ def main():
356345
cap = cv2.VideoCapture(input_stream)
357346
wait_key_time = 1
358347

359-
# ----------------------------------------- 5. Loading model to the plugin -----------------------------------------
348+
# ----------------------------------------- 4. Loading model to the plugin -----------------------------------------
360349
log.info("Loading model to the plugin")
361350
exec_nets = {}
362351

@@ -375,7 +364,7 @@ def main():
375364
event = threading.Event()
376365
callback_exceptions = []
377366

378-
# ----------------------------------------------- 6. Doing inference -----------------------------------------------
367+
# ----------------------------------------------- 5. Doing inference -----------------------------------------------
379368
log.info("Starting inference...")
380369
print("To close the application, press 'CTRL+C' here or switch to the output window and press ESC key")
381370
print("To switch between min_latency/user_specified modes, press TAB key in the output window")

demos/python_demos/segmentation_demo/segmentation_demo.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,6 @@ def main():
8181
log.info("Loading network")
8282
net = ie.read_network(args.model, os.path.splitext(args.model)[0] + ".bin")
8383

84-
if "CPU" in args.device:
85-
supported_layers = ie.query_network(net, "CPU")
86-
not_supported_layers = [l for l in net.layers.keys() if l not in supported_layers]
87-
if len(not_supported_layers) != 0:
88-
log.error("Following layers are not supported by the plugin for specified device {}:\n {}".
89-
format(args.device, ', '.join(not_supported_layers)))
90-
log.error("Please try to specify cpu extensions library path in sample's command line parameters using -l "
91-
"or --cpu_extension command line argument")
92-
sys.exit(1)
9384
assert len(net.input_info) == 1, "Sample supports only single input topologies"
9485
assert len(net.outputs) == 1, "Sample supports only single output topologies"
9586

demos/python_demos/text_spotting_demo/text_spotting_demo.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,6 @@ def main():
192192
log.info('Loading decoder part of text recognition network')
193193
text_dec_net = ie.read_network(args.text_dec_model, os.path.splitext(args.text_dec_model)[0] + '.bin')
194194

195-
if 'CPU' in args.device:
196-
supported_layers = ie.query_network(mask_rcnn_net, 'CPU')
197-
not_supported_layers = [l for l in mask_rcnn_net.layers.keys() if l not in supported_layers]
198-
if len(not_supported_layers) != 0:
199-
log.error('Following layers are not supported by the plugin for specified device {}:\n {}'.
200-
format(args.device, ', '.join(not_supported_layers)))
201-
log.error("Please try to specify cpu extensions library path in sample's command line parameters using -l "
202-
"or --cpu_extension command line argument")
203-
sys.exit(1)
204-
205195
required_input_keys = {'im_data', 'im_info'}
206196
assert required_input_keys == set(mask_rcnn_net.input_info), \
207197
'Demo supports only topologies with the following input keys: {}'.format(', '.join(required_input_keys))

demos/python_demos/whiteboard_inpainting_demo/utils/ie_tools.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,6 @@ def load_ie_model(self, ie, model_xml, device, cpu_extension=''):
6868
log.info("Loading network files:\n\t%s\n\t%s", model_xml, model_bin)
6969
net = ie.read_network(model=model_xml, weights=model_bin)
7070

71-
if "CPU" in device:
72-
supported_layers = ie.query_network(net, "CPU")
73-
not_supported_layers = [l for l in net.layers.keys() if l not in supported_layers]
74-
if not_supported_layers:
75-
log.error("Following layers are not supported by the plugin for specified device %s:\n %s",
76-
device, ', '.join(not_supported_layers))
77-
log.error("Please try to specify cpu extensions library path in sample's command line parameters using -l "
78-
"or --cpu_extension command line argument")
79-
sys.exit(1)
80-
8171
assert len(net.input_info) in self.get_allowed_inputs_len(), \
8272
"Supports topologies with only {} inputs, but got {}" \
8373
.format(self.get_allowed_inputs_len(), len(net.input_info))

0 commit comments

Comments
 (0)