コード例 #1
0
 def test_create_input_feeder_config_inputs_contain_only_const_inputs_with_not_list_value(
         self):
     input_feeder = InputFeeder([{
         'name': 'const_data',
         'type': 'CONST_INPUT',
         'value': 'value'
     }], {
         'data': (1, 3, 10, 10),
         'const_data': (1, 4)
     })
     assert input_feeder.const_inputs['const_data'] == 'value'
     assert not input_feeder.inputs_mapping
     assert input_feeder.non_constant_inputs == ['data']
コード例 #2
0
 def test_fill_non_constant_inputs_with_specific_mapping_not_match_raise_config_error(
         self):
     input_feeder = InputFeeder(
         [{
             'name': 'input1',
             'type': 'INPUT',
             'value': '0'
         }, {
             'name': 'input2',
             'type': 'INPUT',
             'value': '1'
         }], {
             'input1': InputInfo_test(shape=(1, 3, 10, 10)),
             'input2': InputInfo_test(shape=(1, 3, 10, 10))
         })
     with pytest.raises(ConfigError):
         input_feeder.fill_non_constant_inputs([
             DataRepresentation(
                 [np.zeros((10, 10, 3)),
                  np.ones((10, 10, 3))],
                 identifier=['0', '2'])
         ])
コード例 #3
0
 def test_create_input_feeder_config_inputs_contain_only_const_inputs_with_list_value(
         self):
     input_feeder = InputFeeder([{
         'name': 'const_data',
         'type': 'CONST_INPUT',
         'value': [1, 1, 1, 1]
     }], {
         'data': (1, 3, 10, 10),
         'const_data': (1, 4)
     })
     assert np.array_equal(input_feeder.const_inputs['const_data'],
                           np.ones(4))
     assert not input_feeder.inputs_mapping
     assert input_feeder.non_constant_inputs == ['data']
コード例 #4
0
 def test_fill_non_constant_inputs_with_specific_mapping_batch_1(self):
     input_feeder = InputFeeder(
         [{
             'name': 'input1',
             'type': 'INPUT',
             'value': '0'
         }, {
             'name': 'input2',
             'type': 'INPUT',
             'value': '1'
         }], {
             'input1': InputInfo_test(shape=(1, 3, 10, 10)),
             'input2': InputInfo_test(shape=(1, 3, 10, 10))
         })
     result = input_feeder.fill_non_constant_inputs([
         DataRepresentation([np.zeros(
             (10, 10, 3)), np.ones((10, 10, 3))],
                            identifier=['0', '1'])
     ])[0]
     expected_data = [np.zeros((1, 3, 10, 10)), np.ones((1, 3, 10, 10))]
     assert 'input1' in result
     assert np.array_equal(result['input1'], expected_data[0])
     assert 'input2' in result
     assert np.array_equal(result['input2'], expected_data[1])
コード例 #5
0
 def test_create_input_feeder_with_precision_info_for_specific_layer(self):
     input_feeder = InputFeeder([{
         'name': 'const_data',
         'type': 'CONST_INPUT',
         'value': [[1, 2, 3, 4]],
         'precision': 'FP32'
     }], {
         'data': (1, 3, 10, 10),
         'const_data': (1, 4)
     },
                                input_precisions_list=['data:U8'])
     assert 'const_data' in input_feeder.precision_mapping
     assert input_feeder.precision_mapping['const_data'] == np.float32
     assert input_feeder.const_inputs['const_data'].dtype == np.float32
     assert len(input_feeder.inputs_config) == 2
     assert input_feeder.inputs_config[0][
         'name'] == 'const_data' and input_feeder.inputs_config[0][
             'precision'] == 'FP32'
     assert input_feeder.inputs_config[1][
         'name'] == 'data' and input_feeder.inputs_config[1][
             'precision'] == 'U8'
コード例 #6
0
 def test_create_input_feeder_with_config_inputs_not_in_network_inputs_raise_config_error(self):
     with pytest.raises(ConfigError):
         InputFeeder([{'name': 'data2', 'type': 'INPUT', 'value': '.'}], {'data': (1, 3, 10, 10)})
コード例 #7
0
 def test_create_input_feeder_with_config_inputs_and_empty_network_inputs_raise_config_error(self):
     with pytest.raises(ConfigError):
         InputFeeder([{'name': 'const_data', 'type': 'CONST_INPUT', 'value': '[1, 1, 1, 1]'}], {})
コード例 #8
0
 def test_set_invalid_input_precision_for_image_info_input_raise_config_error(self):
     with pytest.raises(ConfigError):
         InputFeeder([{'name': 'im_info', 'type': 'IMAGE_INFO', 'precision': 'U2'}],
                     {'input': (1, 3, 10, 10), 'im_info': (1, 3)})
コード例 #9
0
 def test_set_invalid_input_precision_for_non_constant_input_raise_config_error(self):
     with pytest.raises(ConfigError):
         InputFeeder([{'name': 'input', 'type': 'INPUT', 'precision': 'U2'}], {'input': (1, 3, 10, 10)})
コード例 #10
0
 def test_create_input_feeder_without_inputs_raise_config_error(self):
     with pytest.raises(ConfigError):
         InputFeeder([], {})
コード例 #11
0
 def test_create_input_feeder_config_inputs_fully_match_to_network_inputs(self):
     input_feeder = InputFeeder([{'name': 'data', 'type': 'INPUT', 'value': '.'}], {'data': (1, 3, 10, 10)})
     assert not input_feeder.const_inputs
     assert input_feeder.inputs_mapping == {'data': re.compile('.')}
     assert input_feeder.non_constant_inputs == ['data']
コード例 #12
0
 def test_fill_non_constant_input_with_specific_mapping_several_image_matched(self):
     input_feeder = InputFeeder([{'name': 'input', 'type': 'INPUT', 'value': '.'}], {'input': InputInfo_test(shape=(1, 3, 10, 10))})
     result = input_feeder.fill_non_constant_inputs([DataRepresentation([np.zeros((10, 10, 3)), np.ones((10, 10, 3))], identifier=['0', '1'])])[0]
     expected_data = np.zeros((1, 3, 10, 10))
     assert 'input' in result
     assert np.array_equal(result['input'], expected_data)
コード例 #13
0
 def test_fill_non_constant_input_with_one_input_without_specific_mapping_batch_1(self):
     input_feeder = InputFeeder([], { 'input': InputInfo_test(shape=(1, 3, 10, 10)) })
     result = input_feeder.fill_non_constant_inputs([DataRepresentation(np.zeros((10, 10, 3)), identifier='0')])[0]
     expected_data = np.zeros((1, 3, 10, 10))
     assert 'input' in result
     assert np.array_equal(result['input'], expected_data)
コード例 #14
0
 def test_create_input_feeder_with_several_precision_info_in_wrong_format_raises_config_error(self):
     with pytest.raises(ConfigError):
         InputFeeder(
             [{'name': 'const_data', 'type': 'CONST_INPUT', 'value': [[1, 2, 3, 4]], 'precision': 'FP32'}],
             {'data': (1, 3, 10, 10), 'const_data': (1, 4)}, input_precisions_list=['U8', 'FP16']
         )
コード例 #15
0
 def test_create_input_feeder_with_only_image_info_in_network_inputs_raise_config_error(self):
     with pytest.raises(ConfigError):
         InputFeeder([{'name': 'info', 'type': 'IMAGE_INFO'}], {'info': (1, 3)})
コード例 #16
0
 def test_set_input_precision_for_constant_input(self):
     input_feeder = InputFeeder(
         [{'name': 'input_u8', 'type': 'CONST_INPUT', 'value': [1, 2, 3], 'precision': 'U8'}],
         {'input': (1, 3, 10, 10), 'input_u8': (3,)})
     assert input_feeder.const_inputs['input_u8'].dtype == np.uint8
コード例 #17
0
 def test_create_input_feeder_without_config_inputs(self):
     input_feeder = InputFeeder([], {'data': (1, 3, 10, 10)})
     assert not input_feeder.const_inputs
     assert not input_feeder.inputs_mapping
     assert input_feeder.non_constant_inputs == ['data']
コード例 #18
0
 def test_set_invalid_input_precision_for_constant_input_raise_config_error(self):
     with pytest.raises(ConfigError):
         InputFeeder(
             [{'name': 'input_u8', 'type': 'CONST_INPUT', 'value': [1, 2, 3], 'precision': 'U2'}],
             {'input': (1, 3, 10, 10), 'input_u8': (3,)})
コード例 #19
0
 def test_create_input_feeder_not_all_non_constant_inputs_in_config_raise_config_error(self):
     with pytest.raises(ConfigError):
         InputFeeder(
             [{'name': '0', 'type': 'INPUT', 'value': '.'}],
             {'0': (1, 3, 10, 10), '1': (1, 3, 10, 10)}
         )
コード例 #20
0
 def test_create_input_feeder_with_config_iamge_info_not_in_network_inputs_raise_config_error(self):
     with pytest.raises(ConfigError):
         InputFeeder([{'name': 'info', 'type': 'IMAGE_INFO'}], {'data': (1, 3, 10, 10)})