Skip to content

Commit 9109841

Browse files
authored
Merge branch 'openvinotoolkit:master' into master
2 parents 3eb05dd + 1fa75fd commit 9109841

File tree

51 files changed

+668
-1191
lines changed

Some content is hidden

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

51 files changed

+668
-1191
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@
4141
/tools/model_tools/** omz.ci.job-for-change.downloader
4242

4343
*.md omz.ci.job-for-change.documentation -omz.ci.job-for-change.ac -omz.ci.job-for-change.demos -omz.ci.job-for-change.downloader
44+
45+
/models/intel/device_support.md omz.ci.job-for-change.demos
46+
/models/public/device_support.md omz.ci.job-for-change.demos

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# [OpenVINO™ Toolkit](https://docs.openvino.ai/latest/index.html) - Open Model Zoo repository
2-
[![Stable release](https://img.shields.io/badge/version-2021.4-green.svg)](https://github.com/openvinotoolkit/open_model_zoo/releases/tag/2022.1)
2+
[![Stable release](https://img.shields.io/badge/version-2022.1-green.svg)](https://github.com/openvinotoolkit/open_model_zoo/releases/tag/2022.1)
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

ci/dependencies.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
opencv_linux: '20220210_0636-4.5.5_043'
2-
opencv_windows: '20220210_0636-4.5.5_043'
3-
openvino_linux: '2022.1.0.582'
4-
openvino_windows: '2022.1.0.582'
5-
wheel_linux: '2022.1.0.dev20220211-6610'
6-
wheel_windows: '2022.1.0.dev20220211-6610'
1+
opencv_linux: '20220215_0649-4.5.5_053'
2+
opencv_windows: '20220215_0649-4.5.5_053'
3+
openvino_linux: '2022.1.0.592'
4+
openvino_windows: '2022.1.0.592'
5+
wheel_linux: '2022.1.0.dev20220215-6682'
6+
wheel_windows: '2022.1.0.dev20220215-6682'

demos/common/cpp/models/include/models/detection_model_yolo.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ class ModelYolo : public DetectionModel {
2727
class Region {
2828
public:
2929
int num = 0;
30-
int classes = 0;
30+
size_t classes = 0;
3131
int coords = 0;
3232
std::vector<float> anchors;
33-
int outputWidth = 0;
34-
int outputHeight = 0;
33+
size_t outputWidth = 0;
34+
size_t outputHeight = 0;
3535

3636
Region(const std::shared_ptr<ov::op::v0::RegionYolo>& regionYolo);
37-
Region(int classes, int coords, const std::vector<float>& anchors, const std::vector<int64_t>& masks, int outputWidth, int outputHeight);
37+
Region(size_t classes, int coords, const std::vector<float>& anchors, const std::vector<int64_t>& masks, size_t outputWidth, size_t outputHeight);
3838
};
3939

4040
public:
@@ -75,7 +75,7 @@ class ModelYolo : public DetectionModel {
7575
const unsigned long resized_im_h, const unsigned long resized_im_w, const unsigned long original_im_h,
7676
const unsigned long original_im_w, std::vector<DetectedObject>& objects);
7777

78-
static int calculateEntryIndex(int entriesNum, int lcoords, int lclasses, int location, int entry);
78+
static int calculateEntryIndex(int entriesNum, int lcoords, size_t lclasses, int location, int entry);
7979
static double intersectionOverUnion(const DetectedObject& o1, const DetectedObject& o2);
8080

8181
std::map<std::string, Region> regions;

demos/common/cpp/models/src/detection_model_yolo.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,15 @@ void ModelYolo::prepareInputsOutputs(std::shared_ptr<ov::Model>& model) {
181181

182182
for (const auto& name : outputsNames) {
183183
const auto& shape = outShapes[name];
184-
int classes = (int)shape[ov::layout::channels_idx(yoloRegionLayout)] / num - 4 - (isObjConf ? 1 : 0);
185184
if (shape[ov::layout::channels_idx(yoloRegionLayout)] % num != 0) {
186185
throw std::logic_error(std::string("Output tenosor ") + name + " has wrong 2nd dimension");
187186
}
188-
regions.emplace(name, Region(classes, 4,
187+
regions.emplace(name, Region(
188+
shape[ov::layout::channels_idx(yoloRegionLayout)] / num - 4 - (isObjConf ? 1 : 0),
189+
4,
189190
presetAnchors.size() ? presetAnchors : defaultAnchors[yoloVersion],
190191
std::vector<int64_t>(chosenMasks.begin() + i * num, chosenMasks.begin() + (i + 1) * num),
191-
(int)shape[ov::layout::width_idx(yoloRegionLayout)], (int)shape[ov::layout::height_idx(yoloRegionLayout)]));
192+
shape[ov::layout::width_idx(yoloRegionLayout)], shape[ov::layout::height_idx(yoloRegionLayout)]));
192193
i++;
193194
}
194195
}
@@ -315,7 +316,7 @@ void ModelYolo::parseYOLOOutput(const std::string& output_name,
315316
obj.width = clamp(width, 0.f, (float)original_im_w - obj.x);
316317
obj.height = clamp(height, 0.f, (float)original_im_h - obj.y);
317318

318-
for (int j = 0; j < region.classes; ++j) {
319+
for (size_t j = 0; j < region.classes; ++j) {
319320
int class_index = calculateEntryIndex(entriesNum, region.coords, region.classes + isObjConf, n * entriesNum + i, region.coords + isObjConf + j);
320321
float prob = scale * postprocessRawData(outData[class_index]);
321322

@@ -332,7 +333,7 @@ void ModelYolo::parseYOLOOutput(const std::string& output_name,
332333
}
333334
}
334335

335-
int ModelYolo::calculateEntryIndex(int totalCells, int lcoords, int lclasses, int location, int entry) {
336+
int ModelYolo::calculateEntryIndex(int totalCells, int lcoords, size_t lclasses, int location, int entry) {
336337
int n = location / totalCells;
337338
int loc = location % totalCells;
338339
return (n * (lcoords + lclasses) + entry) * totalCells + loc;
@@ -353,8 +354,8 @@ ModelYolo::Region::Region(const std::shared_ptr<ov::op::v0::RegionYolo>& regionY
353354
num = mask.size();
354355

355356
auto shape = regionYolo->get_input_shape(0);
356-
outputWidth = (int)shape[3];
357-
outputHeight = (int)shape[2];
357+
outputWidth = shape[3];
358+
outputHeight = shape[2];
358359

359360
if (num) {
360361

@@ -377,7 +378,7 @@ ModelYolo::Region::Region(const std::shared_ptr<ov::op::v0::RegionYolo>& regionY
377378
}
378379
}
379380

380-
ModelYolo::Region::Region(int classes, int coords, const std::vector<float>& anchors, const std::vector<int64_t>& masks, int outputWidth, int outputHeight) :
381+
ModelYolo::Region::Region(size_t classes, int coords, const std::vector<float>& anchors, const std::vector<int64_t>& masks, size_t outputWidth, size_t outputHeight) :
381382
classes(classes), coords(coords),
382383
outputWidth(outputWidth), outputHeight(outputHeight) {
383384
num = masks.size();

demos/common/cpp/utils/include/utils/kuhn_munkres.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class KuhnMunkres {
3131
/// \return Optimal column index for each row. -1 means that there is no
3232
/// column for row.
3333
///
34-
std::vector<int> Solve(const cv::Mat &dissimilarity_matrix);
34+
std::vector<size_t> Solve(const cv::Mat &dissimilarity_matrix);
3535

3636
private:
3737
static constexpr int kStar = 1;

demos/common/cpp/utils/src/kuhn_munkres.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
KuhnMunkres::KuhnMunkres(bool greedy) : n_(), greedy_(greedy) {}
1212

13-
std::vector<int> KuhnMunkres::Solve(const cv::Mat& dissimilarity_matrix) {
13+
std::vector<size_t> KuhnMunkres::Solve(const cv::Mat& dissimilarity_matrix) {
1414
CV_Assert(dissimilarity_matrix.type() == CV_32F);
1515
double min_val;
1616
cv::minMaxLoc(dissimilarity_matrix, &min_val);
@@ -28,12 +28,12 @@ std::vector<int> KuhnMunkres::Solve(const cv::Mat& dissimilarity_matrix) {
2828

2929
Run();
3030

31-
std::vector<int> results(dissimilarity_matrix.rows, -1);
31+
std::vector<size_t> results(dissimilarity_matrix.rows, -1);
3232
for (int i = 0; i < dissimilarity_matrix.rows; i++) {
3333
const auto ptr = marked_.ptr<char>(i);
3434
for (int j = 0; j < dissimilarity_matrix.cols; j++) {
3535
if (ptr[j] == kStar) {
36-
results[i] = j;
36+
results[i] = (size_t)j;
3737
}
3838
}
3939
}

demos/common/python/openvino/model_zoo/model_api/models/instance_segmentation.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2020 Intel Corporation
2+
Copyright (c) 2020-2022 Intel Corporation
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -19,8 +19,8 @@
1919

2020
from .image_model import ImageModel
2121
from .model import WrapperError
22-
from .types import NumericalValue
23-
from .utils import nms
22+
from .types import NumericalValue, ListValue, StringValue
23+
from .utils import nms, load_labels
2424

2525

2626
class MaskRCNNModel(ImageModel):
@@ -29,6 +29,8 @@ class MaskRCNNModel(ImageModel):
2929
def __init__(self, model_adapter, configuration, preload=False):
3030
super().__init__(model_adapter, configuration, preload)
3131
self._check_io_number((1, 2), (3, 4, 5, 8))
32+
if self.path_to_labels:
33+
self.labels = load_labels(self.path_to_labels)
3234
self.is_segmentoly = len(self.inputs) == 2
3335
self.output_blob_name = self._get_outputs()
3436

@@ -40,6 +42,10 @@ def parameters(cls):
4042
default_value=0.5,
4143
description='Probability threshold for detections filtering'
4244
),
45+
'labels': ListValue(description="List of class labels"),
46+
'path_to_labels': StringValue(
47+
description="Path to file with labels. Overrides the labels"
48+
),
4349
})
4450
return parameters
4551

@@ -150,6 +156,8 @@ class YolactModel(ImageModel):
150156

151157
def __init__(self, model_adapter, configuration, preload=False):
152158
super().__init__(model_adapter, configuration, preload)
159+
if self.path_to_labels:
160+
self.labels = load_labels(self.path_to_labels)
153161
self._check_io_number(1, 4)
154162
self.output_blob_name = self._get_outputs()
155163

@@ -161,6 +169,10 @@ def parameters(cls):
161169
default_value=0.5,
162170
description='Probability threshold for detections filtering'
163171
),
172+
'labels': ListValue(description="List of class labels"),
173+
'path_to_labels': StringValue(
174+
description="Path to file with labels. Overrides the labels"
175+
),
164176
})
165177
return parameters
166178

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
Copyright (C) 2022 Intel Corporation
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
"""
16+
17+
from .drawing_utils import ColorPalette
18+
from .instance_segmentation import InstanceSegmentationVisualizer
19+
20+
__all__ = [
21+
'ColorPalette',
22+
'InstanceSegmentationVisualizer',
23+
]
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"""
2+
Copyright (c) 2022 Intel Corporation
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
"""
16+
17+
import random
18+
import colorsys
19+
20+
import numpy as np
21+
22+
23+
class ColorPalette:
24+
def __init__(self, n, rng=None):
25+
if n == 0:
26+
raise ValueError('ColorPalette accepts only the positive number of colors')
27+
if rng is None:
28+
rng = random.Random(0xACE) # nosec - disable B311:random check
29+
30+
candidates_num = 100
31+
hsv_colors = [(1.0, 1.0, 1.0)]
32+
for _ in range(1, n):
33+
colors_candidates = [(rng.random(), rng.uniform(0.8, 1.0), rng.uniform(0.5, 1.0))
34+
for _ in range(candidates_num)]
35+
min_distances = [self.min_distance(hsv_colors, c) for c in colors_candidates]
36+
arg_max = np.argmax(min_distances)
37+
hsv_colors.append(colors_candidates[arg_max])
38+
39+
self.palette = [self.hsv2rgb(*hsv) for hsv in hsv_colors]
40+
41+
@staticmethod
42+
def dist(c1, c2):
43+
dh = min(abs(c1[0] - c2[0]), 1 - abs(c1[0] - c2[0])) * 2
44+
ds = abs(c1[1] - c2[1])
45+
dv = abs(c1[2] - c2[2])
46+
return dh * dh + ds * ds + dv * dv
47+
48+
@classmethod
49+
def min_distance(cls, colors_set, color_candidate):
50+
distances = [cls.dist(o, color_candidate) for o in colors_set]
51+
return np.min(distances)
52+
53+
@staticmethod
54+
def hsv2rgb(h, s, v):
55+
return tuple(round(c * 255) for c in colorsys.hsv_to_rgb(h, s, v))
56+
57+
def __getitem__(self, n):
58+
return self.palette[n % len(self.palette)]
59+
60+
def __len__(self):
61+
return len(self.palette)

0 commit comments

Comments
 (0)