Skip to content

Commit 912eead

Browse files
author
Roman Donchenko
authored
Merge pull request #1185 from opencv/release
Merge OpenVINO toolkit 2020.3 content into master
2 parents 17acb03 + 12a3ca8 commit 912eead

File tree

122 files changed

+1216
-940
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+1216
-940
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# [OpenVINO™ Toolkit](https://01.org/openvinotoolkit) - Open Model Zoo repository
2-
[![Stable release](https://img.shields.io/badge/version-2020.2-green.svg)](https://github.com/opencv/open_model_zoo/releases/tag/2020.2)
2+
[![Stable release](https://img.shields.io/badge/version-2020.3-green.svg)](https://github.com/opencv/open_model_zoo/releases/tag/2020.3)
33
[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/open_model_zoo/community)
44
[![Apache License Version 2.0](https://img.shields.io/badge/license-Apache_2.0-green.svg)](LICENSE)
55

demos/common/monitors/cpu_monitor.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ class CpuMonitor::PerformanceCounter {
5252
for (std::size_t i = 0; i < coreTimeCounters.size(); ++i) {
5353
status = PdhGetFormattedCounterValue(coreTimeCounters[i], PDH_FMT_DOUBLE, NULL,
5454
&displayValue);
55-
if (ERROR_SUCCESS != status) {
56-
throw std::system_error(status, std::system_category(), "PdhGetFormattedCounterValue() failed");
55+
switch (status) {
56+
case ERROR_SUCCESS: break;
57+
// PdhGetFormattedCounterValue() can sometimes return PDH_CALC_NEGATIVE_DENOMINATOR for some reason
58+
case PDH_CALC_NEGATIVE_DENOMINATOR: return {};
59+
default:
60+
throw std::system_error(status, std::system_category(), "PdhGetFormattedCounterValue() failed");
5761
}
5862
if (PDH_CSTATUS_VALID_DATA != displayValue.CStatus && PDH_CSTATUS_NEW_DATA != displayValue.CStatus) {
5963
throw std::runtime_error("Error in counter data");
@@ -125,6 +129,7 @@ class CpuMonitor::PerformanceCounter {
125129
cpuLoad[i] = 1.0
126130
- idleDiff / clockTicks / std::chrono::duration_cast<Sec>(timePoint - prevTimePoint).count();
127131
}
132+
prevTimePoint = timePoint;
128133
return cpuLoad;
129134
}
130135
return {};

demos/object_detection_demo_ssd_async/main.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,8 @@ int main(int argc, char *argv[]) {
188188
break;
189189
}
190190
}
191-
} else {
192-
const CNNLayerPtr outputLayer = cnnNetwork.getLayerByName(outputName.c_str());
193-
if (outputLayer->type != "DetectionOutput") {
194-
throw std::logic_error("Object Detection network output layer(" + outputLayer->name +
195-
") should be DetectionOutput, but was " + outputLayer->type);
196-
}
197-
198-
num_classes = outputLayer->GetParamAsInt("num_classes");
191+
} else if (!labels.empty()) {
192+
throw std::logic_error("Class labels are not supported with IR version older than 10");
199193
}
200194

201195
if (static_cast<int>(labels.size()) != num_classes) {

demos/python_demos/3d_segmentation_demo/3d_segmentation_demo.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from scipy.ndimage import interpolation
2929
from sys import stdout
3030

31-
from openvino.inference_engine import IENetwork, IECore
31+
from openvino.inference_engine import IECore
3232

3333

3434
logging.basicConfig(format="[ %(levelname)s ] %(message)s", level=logging.INFO, stream=stdout)
@@ -269,11 +269,7 @@ def main():
269269
logger.info("Plugin version is {}".format(version_str))
270270

271271
# --------------------- 2. Read IR Generated by ModelOptimizer (.xml and .bin files) ---------------------
272-
273-
xml_filename = os.path.abspath(args.path_to_model)
274-
bin_filename = os.path.abspath(os.path.splitext(xml_filename)[0] + '.bin')
275-
276-
ie_network = IENetwork(xml_filename, bin_filename)
272+
ie_network = ie.read_network(args.path_to_model, os.path.splitext(args.path_to_model)[0] + '.bin')
277273

278274
input_info = ie_network.inputs
279275
if len(input_info) == 0:

demos/python_demos/action_recognition/action_recognition_demo/models.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import cv2
2121
import numpy as np
22-
from openvino.inference_engine import IENetwork
2322

2423

2524
def center_crop(frame, crop_size):
@@ -87,7 +86,7 @@ def __init__(self, model_xml, model_bin, ie_core, target_device, num_requests, b
8786

8887
# Read IR
8988
print("Reading IR...")
90-
self.net = IENetwork(model_xml, model_bin)
89+
self.net = ie_core.read_network(model_xml, model_bin)
9190
self.net.batch_size = batch_size
9291
assert len(self.net.inputs.keys()) == 1, "One input is expected"
9392
assert len(self.net.outputs) == 1, "One output is expected"

demos/python_demos/asl_recognition_demo/asl_recognition_demo/common.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
"""
1616

17-
from openvino.inference_engine import IENetwork, IECore # pylint: disable=no-name-in-module
17+
from openvino.inference_engine import IECore # pylint: disable=no-name-in-module
1818

1919

2020
def load_ie_core(device, cpu_extension=None):
@@ -34,9 +34,7 @@ def __init__(self, model_path, device, ie_core, num_requests, output_shape=None)
3434
"""Constructor"""
3535
if model_path.endswith((".xml", ".bin")):
3636
model_path = model_path[:-4]
37-
model_xml = model_path + ".xml"
38-
model_bin = model_path + ".bin"
39-
self.net = IENetwork(model=model_xml, weights=model_bin)
37+
self.net = ie_core.read_network(model_path + ".xml", model_path + ".bin")
4038
assert len(self.net.inputs.keys()) == 1, "One input is expected"
4139

4240
supported_layers = ie_core.query_network(self.net, device)

demos/python_demos/colorization_demo/colorization_demo.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
limitations under the License.
1616
"""
1717

18-
from openvino.inference_engine import IENetwork, IECore
18+
from openvino.inference_engine import IECore
1919
import cv2 as cv
2020
import numpy as np
2121
import os
@@ -48,18 +48,17 @@ def build_arg():
4848

4949
if __name__ == '__main__':
5050
args = build_arg().parse_args()
51-
model_path = os.path.splitext(args.model)[0]
52-
weights_bin = model_path + ".bin"
5351
coeffs = args.coeffs
5452

5553
# mean is stored in the source caffe model and passed to IR
5654
log.basicConfig(format="[ %(levelname)s ] %(message)s",
5755
level=log.INFO if not args.verbose else log.DEBUG, stream=sys.stdout)
5856

5957
log.debug("Load network")
60-
load_net = IENetwork(model=args.model, weights=weights_bin)
58+
ie = IECore()
59+
load_net = ie.read_network(args.model, os.path.splitext(args.model)[0] + ".bin")
6160
load_net.batch_size = 1
62-
exec_net = IECore().load_network(network=load_net, device_name=args.device)
61+
exec_net = ie.load_network(network=load_net, device_name=args.device)
6362

6463
assert len(load_net.inputs) == 1, "Expected number of inputs is equal 1"
6564
input_blob = next(iter(load_net.inputs))

demos/python_demos/face_recognition_demo/face_recognition_demo.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import cv2
2525
import numpy as np
2626

27-
from openvino.inference_engine import IENetwork
2827
from ie_module import InferenceContext
2928
from landmarks_detector import LandmarksDetector
3029
from face_detector import FaceDetector
@@ -167,14 +166,13 @@ def __init__(self, args):
167166

168167
def load_model(self, model_path):
169168
model_path = osp.abspath(model_path)
170-
model_description_path = model_path
171169
model_weights_path = osp.splitext(model_path)[0] + ".bin"
172-
log.info("Loading the model from '%s'" % (model_description_path))
173-
assert osp.isfile(model_description_path), \
174-
"Model description is not found at '%s'" % (model_description_path)
170+
log.info("Loading the model from '%s'" % (model_path))
171+
assert osp.isfile(model_path), \
172+
"Model description is not found at '%s'" % (model_path)
175173
assert osp.isfile(model_weights_path), \
176174
"Model weights are not found at '%s'" % (model_weights_path)
177-
model = IENetwork(model_description_path, model_weights_path)
175+
model = self.context.ie_core.read_network(model_path, model_weights_path)
178176
log.info("Model is loaded")
179177
return model
180178

@@ -242,7 +240,7 @@ def __init__(self, args):
242240
self.print_perf_stats = args.perf_stats
243241

244242
self.frame_time = 0
245-
self.frame_start_time = 0
243+
self.frame_start_time = time.perf_counter()
246244
self.fps = 0
247245
self.frame_num = 0
248246
self.frame_count = -1
@@ -254,8 +252,8 @@ def __init__(self, args):
254252
self.frame_timeout = 0 if args.timelapse else 1
255253

256254
def update_fps(self):
257-
now = time.time()
258-
self.frame_time = now - self.frame_start_time
255+
now = time.perf_counter()
256+
self.frame_time = max(now - self.frame_start_time, sys.float_info.epsilon)
259257
self.fps = 1.0 / self.frame_time
260258
self.frame_start_time = now
261259

demos/python_demos/handwritten_japanese_recognition_demo/handwritten_japanese_recognition_demo.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import cv2
2222
import numpy as np
2323

24-
from openvino.inference_engine import IENetwork, IECore
24+
from openvino.inference_engine import IECore
2525
from utils.codec import CTCCodec
2626

2727

@@ -66,14 +66,12 @@ def preprocess_input(image_name, height, width):
6666
def main():
6767
log.basicConfig(format="[ %(levelname)s ] %(message)s", level=log.INFO, stream=sys.stdout)
6868
args = build_argparser().parse_args()
69-
model_xml = args.model
70-
model_bin = os.path.splitext(model_xml)[0] + ".bin"
7169

7270
# Plugin initialization
7371
ie = IECore()
7472
# Read IR
75-
log.info("Loading network files:\n\t{}\n\t{}".format(model_xml, model_bin))
76-
net = IENetwork(model=model_xml, weights=model_bin)
73+
log.info("Loading network")
74+
net = ie.read_network(args.model, os.path.splitext(args.model)[0] + ".bin")
7775

7876
assert len(net.inputs) == 1, "Demo supports only single input topologies"
7977
assert len(net.outputs) == 1, "Demo supports only single output topologies"

demos/python_demos/human_pose_estimation_3d_demo/modules/inference_engine.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,24 @@
1616

1717
import numpy as np
1818

19-
from openvino.inference_engine import IENetwork, IECore
19+
from openvino.inference_engine import IECore
2020

2121

2222
class InferenceEngine:
2323
def __init__(self, net_model_xml_path, device, stride):
2424
self.device = device
2525
self.stride = stride
2626

27-
net_model_bin_path = os.path.splitext(net_model_xml_path)[0] + '.bin'
28-
self.net = IENetwork(model=net_model_xml_path, weights=net_model_bin_path)
27+
self.ie = IECore()
28+
29+
self.net = self.ie.read_network(net_model_xml_path, os.path.splitext(net_model_xml_path)[0] + '.bin')
2930
required_input_key = {'data'}
3031
assert required_input_key == set(self.net.inputs.keys()), \
3132
'Demo supports only topologies with the following input key: {}'.format(', '.join(required_input_key))
3233
required_output_keys = {'features', 'heatmaps', 'pafs'}
3334
assert required_output_keys.issubset(self.net.outputs.keys()), \
3435
'Demo supports only topologies with the following output keys: {}'.format(', '.join(required_output_keys))
3536

36-
self.ie = IECore()
3737
self.exec_net = self.ie.load_network(network=self.net, num_requests=1, device_name=device)
3838

3939
def infer(self, img):

0 commit comments

Comments
 (0)