Publishing 2019 R1 content
[platform/upstream/dldt.git] / model-optimizer / mo / front / mxnet / extractors / multibox_detection.py
1 """
2  Copyright (c) 2018-2019 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 from mo.front.common.partial_infer.multi_box_detection import multi_box_detection_infer
17
18
19 def multi_box_detection_ext(attrs):
20     num_classes = 21
21     top_k = attrs.int("nms_topk", -1)
22     keep_top_k = top_k
23     variance_encoded_in_target = 0
24     code_type = "caffe.PriorBoxParameter.CENTER_SIZE"
25     share_location = 1
26     nms_threshold = attrs.float("nms_threshold", 0.5)
27     confidence_threshold = attrs.float("threshold", 0.01)
28     background_label_id = 0
29     clip = 0 if not attrs.bool("clip", True) else 1
30     node_attrs = {
31         'type': 'DetectionOutput',
32         'num_classes': num_classes,
33         'keep_top_k': keep_top_k,
34         'variance_encoded_in_target': variance_encoded_in_target,
35         'code_type': code_type,
36         'share_location': share_location,
37         'confidence_threshold': confidence_threshold,
38         'background_label_id': background_label_id,
39         'nms_threshold': nms_threshold,
40         'top_k': top_k,
41         'decrease_label_id': 1,
42         'clip': clip,
43         'normalized': 1,
44         'infer': multi_box_detection_infer
45     }
46     return node_attrs