Publishing 2019 R1 content
[platform/upstream/dldt.git] / model-optimizer / mo / front / mxnet / extractors / multibox_prior_test.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
17 import unittest
18
19 import numpy as np
20
21 from mo.front.mxnet.extractors.multibox_prior import multi_box_prior_ext
22 from mo.front.mxnet.extractors.utils import AttrDictionary
23
24
25 class TestMultiBoxPrior_Parsing(unittest.TestCase):
26     def test_multi_box_prior_check_attrs(self):
27         attrs = {
28             'ratios': '(1,2,0.5)',
29             'steps': '(0.02666666666666667, 0.02666666666666667)',
30             'clip': 'False',
31             'sizes': '(0.1,0.141)'
32         }
33
34         res = multi_box_prior_ext(AttrDictionary(attrs))
35         exp_attrs = {
36             'type': 'PriorBox',
37             'img_size': 0,
38             'img_h': 0,
39             'img_w': 0,
40             'step': 0.02666666666666667,
41             'step_h': 0,
42             'step_w': 0,
43             'offset': 0.5,
44             'variance': '0.100000,0.100000,0.200000,0.200000',
45             'flip': 0,
46             'clip': 0,
47             'min_size': (0.1, 0.141),
48             'max_size': '',
49             'aspect_ratio': [1, 2, 0.5],
50         }
51
52         for key in exp_attrs.keys():
53             if key in ['aspect_ratio', 'variance']:
54                 np.testing.assert_equal(res[key], exp_attrs[key])
55             else:
56                 self.assertEqual(res[key], exp_attrs[key])