Example #1
0
    def test_raises_with_multiple_models_tf_dlsdk(self):
        config = {
            'framework': 'dlsdk',
            'tf_model': 'tf_model',
            'model': 'custom_model',
            'weights': 'custom_weights',
            'device': 'cpu',
        }

        with pytest.raises(ConfigError):
            DLSDKLauncher(config)
Example #2
0
    def test_raises_with_multiple_models_onnx_caffe(self):

        config = {
            'framework': 'dlsdk',
            'onnx_model': 'onnx_model',
            'caffe_model': 'caffe_model',
            'caffe_weights': 'caffe_weights',
            'device': 'cpu',
        }

        with pytest.raises(ConfigError):
            DLSDKLauncher(config)
Example #3
0
    def test_raises_with_tf_model_and_tf_meta_both_provided(self):
        config = {
            'framework': 'dlsdk',
            'model': 'custom_model',
            'weights': 'custom_weights',
            'caffe_model': 'caffe_model',
            'caffe_weights': 'caffe_weights',
            'mxnet_weights': 'mxnet_weights',
            'tf_model': 'tf_model',
            'tf_meta': 'tf_meta',
            'device': 'cpu',
        }

        with pytest.raises(ConfigError):
            DLSDKLauncher(config)
Example #4
0
    def test_model_converted_from_tf_checkpoint_with_arg_path_to_obj_detection_api_config(
            self, mocker):
        config = {
            'framework': 'dlsdk',
            'tf_meta': '/path/to/source_models/custom_model',
            'device': 'cpu',
            'adapter': 'classification',
            'mo_params': {
                'tensorflow_object_detection_api_pipeline_config':
                'operations.config'
            },
            '_tf_custom_op_config_dir': 'config/dir',
            '_tf_obj_detection_api_pipeline_config_path': 'od_api'
        }
        mocker.patch(
            'openvino.tools.accuracy_checker.launcher.model_conversion.find_mo',
            return_value=self.FAKE_MO_PATH)
        prepare_args_patch = mocker.patch(
            'openvino.tools.accuracy_checker.launcher.model_conversion.prepare_args'
        )

        args = {
            'input_meta_graph':
            '/path/to/source_models/custom_model',
            'model_name':
            'custom_model',
            'framework':
            'tf',
            'tensorflow_object_detection_api_pipeline_config':
            str(Path('od_api/operations.config'))
        }

        mocker.patch(
            'openvino.tools.accuracy_checker.launcher.model_conversion.exec_mo_binary',
            return_value=subprocess.CompletedProcess(args, returncode=0))
        DLSDKLauncher(config)
        prepare_args_patch.assert_called_once_with(str(self.FAKE_MO_PATH),
                                                   flag_options=[],
                                                   value_options=args)
Example #5
0
    def test_model_converted_from_tf_with_arg_path_to_custom_tf_config(
            self, mocker):
        config = {
            'framework': 'dlsdk',
            'tf_model': '/path/to/source_models/custom_model',
            'device': 'cpu',
            'adapter': 'classification',
            'mo_params': {
                'tensorflow_use_custom_operations_config':
                'ssd_v2_support.json'
            },
            '_tf_custom_op_config_dir': 'config/dir'
        }
        mocker.patch(
            'openvino.tools.accuracy_checker.launcher.model_conversion.find_mo',
            return_value=self.FAKE_MO_PATH)
        prepare_args_patch = mocker.patch(
            'openvino.tools.accuracy_checker.launcher.model_conversion.prepare_args'
        )

        args = {
            'input_model':
            '/path/to/source_models/custom_model',
            'model_name':
            'custom_model',
            'framework':
            'tf',
            'tensorflow_use_custom_operations_config':
            str(Path('config/dir/ssd_v2_support.json'))
        }

        mocker.patch(
            'openvino.tools.accuracy_checker.launcher.model_conversion.exec_mo_binary',
            return_value=subprocess.CompletedProcess(args, returncode=0))
        mo_path = str(self.FAKE_MO_PATH)
        DLSDKLauncher(config)
        prepare_args_patch.assert_called_once_with(mo_path,
                                                   flag_options=[],
                                                   value_options=args)
Example #6
0
    def test_model_converted_from_tf_checkpoint_with_default_path_to_transformations_config(
            self, mocker):
        config = {
            'framework': 'dlsdk',
            'tf_meta': '/path/to/source_models/custom_model',
            'device': 'cpu',
            'adapter': 'classification',
            'mo_params': {
                'transformations_config': 'config.json'
            }
        }
        mocker.patch(
            'openvino.tools.accuracy_checker.launcher.model_conversion.find_mo',
            return_value=self.FAKE_MO_PATH)
        prepare_args_patch = mocker.patch(
            'openvino.tools.accuracy_checker.launcher.model_conversion.prepare_args'
        )

        args = {
            'input_meta_graph':
            '/path/to/source_models/custom_model',
            'model_name':
            'custom_model',
            'framework':
            'tf',
            'transformations_config':
            str(Path('/path/extensions/front/tf/config.json').absolute())
        }

        mocker.patch(
            'openvino.tools.accuracy_checker.launcher.model_conversion.exec_mo_binary',
            return_value=subprocess.CompletedProcess(args, returncode=0))

        DLSDKLauncher(config)
        prepare_args_patch.assert_called_once_with(str(self.FAKE_MO_PATH),
                                                   flag_options=[],
                                                   value_options=args)