Python object_detection.utils.config_util.check_and_parse_input_config_key() Examples

The following are 6 code examples of object_detection.utils.config_util.check_and_parse_input_config_key(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module object_detection.utils.config_util , or try the search function .
Example #1
Source File: config_util_test.py    From vehicle_counting_tensorflow with MIT License 4 votes vote down vote up
def testCheckAndParseInputConfigKey(self):
    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")
    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    pipeline_config.eval_input_reader.add().name = "eval_1"
    pipeline_config.eval_input_reader.add().name = "eval_2"
    _write_config(pipeline_config, pipeline_config_path)
    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)

    specific_shuffle_update_key = "eval_input_configs:eval_2:shuffle"
    is_valid_input_config_key, key_name, input_name, field_name = (
        config_util.check_and_parse_input_config_key(
            configs, specific_shuffle_update_key))
    self.assertTrue(is_valid_input_config_key)
    self.assertEqual(key_name, "eval_input_configs")
    self.assertEqual(input_name, "eval_2")
    self.assertEqual(field_name, "shuffle")

    legacy_shuffle_update_key = "eval_shuffle"
    is_valid_input_config_key, key_name, input_name, field_name = (
        config_util.check_and_parse_input_config_key(configs,
                                                     legacy_shuffle_update_key))
    self.assertTrue(is_valid_input_config_key)
    self.assertEqual(key_name, "eval_input_configs")
    self.assertEqual(input_name, None)
    self.assertEqual(field_name, "shuffle")

    non_input_config_update_key = "label_map_path"
    is_valid_input_config_key, key_name, input_name, field_name = (
        config_util.check_and_parse_input_config_key(
            configs, non_input_config_update_key))
    self.assertFalse(is_valid_input_config_key)
    self.assertEqual(key_name, None)
    self.assertEqual(input_name, None)
    self.assertEqual(field_name, "label_map_path")

    with self.assertRaisesRegexp(ValueError,
                                 "Invalid key format when overriding configs."):
      config_util.check_and_parse_input_config_key(
          configs, "train_input_config:shuffle")

    with self.assertRaisesRegexp(
        ValueError, "Invalid key_name when overriding input config."):
      config_util.check_and_parse_input_config_key(
          configs, "invalid_key_name:train_name:shuffle")

    with self.assertRaisesRegexp(
        ValueError, "Invalid input_name when overriding input config."):
      config_util.check_and_parse_input_config_key(
          configs, "eval_input_configs:unknown_eval_name:shuffle")

    with self.assertRaisesRegexp(
        ValueError, "Invalid field_name when overriding input config."):
      config_util.check_and_parse_input_config_key(
          configs, "eval_input_configs:eval_2:unknown_field_name") 
Example #2
Source File: config_util_test.py    From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 4 votes vote down vote up
def testCheckAndParseInputConfigKey(self):
    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")
    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    pipeline_config.eval_input_reader.add().name = "eval_1"
    pipeline_config.eval_input_reader.add().name = "eval_2"
    _write_config(pipeline_config, pipeline_config_path)
    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)

    specific_shuffle_update_key = "eval_input_configs:eval_2:shuffle"
    is_valid_input_config_key, key_name, input_name, field_name = (
        config_util.check_and_parse_input_config_key(
            configs, specific_shuffle_update_key))
    self.assertTrue(is_valid_input_config_key)
    self.assertEqual(key_name, "eval_input_configs")
    self.assertEqual(input_name, "eval_2")
    self.assertEqual(field_name, "shuffle")

    legacy_shuffle_update_key = "eval_shuffle"
    is_valid_input_config_key, key_name, input_name, field_name = (
        config_util.check_and_parse_input_config_key(configs,
                                                     legacy_shuffle_update_key))
    self.assertTrue(is_valid_input_config_key)
    self.assertEqual(key_name, "eval_input_configs")
    self.assertEqual(input_name, None)
    self.assertEqual(field_name, "shuffle")

    non_input_config_update_key = "label_map_path"
    is_valid_input_config_key, key_name, input_name, field_name = (
        config_util.check_and_parse_input_config_key(
            configs, non_input_config_update_key))
    self.assertFalse(is_valid_input_config_key)
    self.assertEqual(key_name, None)
    self.assertEqual(input_name, None)
    self.assertEqual(field_name, "label_map_path")

    with self.assertRaisesRegexp(ValueError,
                                 "Invalid key format when overriding configs."):
      config_util.check_and_parse_input_config_key(
          configs, "train_input_config:shuffle")

    with self.assertRaisesRegexp(
        ValueError, "Invalid key_name when overriding input config."):
      config_util.check_and_parse_input_config_key(
          configs, "invalid_key_name:train_name:shuffle")

    with self.assertRaisesRegexp(
        ValueError, "Invalid input_name when overriding input config."):
      config_util.check_and_parse_input_config_key(
          configs, "eval_input_configs:unknown_eval_name:shuffle")

    with self.assertRaisesRegexp(
        ValueError, "Invalid field_name when overriding input config."):
      config_util.check_and_parse_input_config_key(
          configs, "eval_input_configs:eval_2:unknown_field_name") 
Example #3
Source File: config_util_test.py    From MAX-Object-Detector with Apache License 2.0 4 votes vote down vote up
def testCheckAndParseInputConfigKey(self):
    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")
    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    pipeline_config.eval_input_reader.add().name = "eval_1"
    pipeline_config.eval_input_reader.add().name = "eval_2"
    _write_config(pipeline_config, pipeline_config_path)
    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)

    specific_shuffle_update_key = "eval_input_configs:eval_2:shuffle"
    is_valid_input_config_key, key_name, input_name, field_name = (
        config_util.check_and_parse_input_config_key(
            configs, specific_shuffle_update_key))
    self.assertTrue(is_valid_input_config_key)
    self.assertEqual(key_name, "eval_input_configs")
    self.assertEqual(input_name, "eval_2")
    self.assertEqual(field_name, "shuffle")

    legacy_shuffle_update_key = "eval_shuffle"
    is_valid_input_config_key, key_name, input_name, field_name = (
        config_util.check_and_parse_input_config_key(configs,
                                                     legacy_shuffle_update_key))
    self.assertTrue(is_valid_input_config_key)
    self.assertEqual(key_name, "eval_input_configs")
    self.assertEqual(input_name, None)
    self.assertEqual(field_name, "shuffle")

    non_input_config_update_key = "label_map_path"
    is_valid_input_config_key, key_name, input_name, field_name = (
        config_util.check_and_parse_input_config_key(
            configs, non_input_config_update_key))
    self.assertFalse(is_valid_input_config_key)
    self.assertEqual(key_name, None)
    self.assertEqual(input_name, None)
    self.assertEqual(field_name, "label_map_path")

    with self.assertRaisesRegexp(ValueError,
                                 "Invalid key format when overriding configs."):
      config_util.check_and_parse_input_config_key(
          configs, "train_input_config:shuffle")

    with self.assertRaisesRegexp(
        ValueError, "Invalid key_name when overriding input config."):
      config_util.check_and_parse_input_config_key(
          configs, "invalid_key_name:train_name:shuffle")

    with self.assertRaisesRegexp(
        ValueError, "Invalid input_name when overriding input config."):
      config_util.check_and_parse_input_config_key(
          configs, "eval_input_configs:unknown_eval_name:shuffle")

    with self.assertRaisesRegexp(
        ValueError, "Invalid field_name when overriding input config."):
      config_util.check_and_parse_input_config_key(
          configs, "eval_input_configs:eval_2:unknown_field_name") 
Example #4
Source File: config_util_test.py    From g-tensorflow-models with Apache License 2.0 4 votes vote down vote up
def testCheckAndParseInputConfigKey(self):
    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")
    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    pipeline_config.eval_input_reader.add().name = "eval_1"
    pipeline_config.eval_input_reader.add().name = "eval_2"
    _write_config(pipeline_config, pipeline_config_path)
    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)

    specific_shuffle_update_key = "eval_input_configs:eval_2:shuffle"
    is_valid_input_config_key, key_name, input_name, field_name = (
        config_util.check_and_parse_input_config_key(
            configs, specific_shuffle_update_key))
    self.assertTrue(is_valid_input_config_key)
    self.assertEqual(key_name, "eval_input_configs")
    self.assertEqual(input_name, "eval_2")
    self.assertEqual(field_name, "shuffle")

    legacy_shuffle_update_key = "eval_shuffle"
    is_valid_input_config_key, key_name, input_name, field_name = (
        config_util.check_and_parse_input_config_key(configs,
                                                     legacy_shuffle_update_key))
    self.assertTrue(is_valid_input_config_key)
    self.assertEqual(key_name, "eval_input_configs")
    self.assertEqual(input_name, None)
    self.assertEqual(field_name, "shuffle")

    non_input_config_update_key = "label_map_path"
    is_valid_input_config_key, key_name, input_name, field_name = (
        config_util.check_and_parse_input_config_key(
            configs, non_input_config_update_key))
    self.assertFalse(is_valid_input_config_key)
    self.assertEqual(key_name, None)
    self.assertEqual(input_name, None)
    self.assertEqual(field_name, "label_map_path")

    with self.assertRaisesRegexp(ValueError,
                                 "Invalid key format when overriding configs."):
      config_util.check_and_parse_input_config_key(
          configs, "train_input_config:shuffle")

    with self.assertRaisesRegexp(
        ValueError, "Invalid key_name when overriding input config."):
      config_util.check_and_parse_input_config_key(
          configs, "invalid_key_name:train_name:shuffle")

    with self.assertRaisesRegexp(
        ValueError, "Invalid input_name when overriding input config."):
      config_util.check_and_parse_input_config_key(
          configs, "eval_input_configs:unknown_eval_name:shuffle")

    with self.assertRaisesRegexp(
        ValueError, "Invalid field_name when overriding input config."):
      config_util.check_and_parse_input_config_key(
          configs, "eval_input_configs:eval_2:unknown_field_name") 
Example #5
Source File: config_util_test.py    From models with Apache License 2.0 4 votes vote down vote up
def testCheckAndParseInputConfigKey(self):
    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")
    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    pipeline_config.eval_input_reader.add().name = "eval_1"
    pipeline_config.eval_input_reader.add().name = "eval_2"
    _write_config(pipeline_config, pipeline_config_path)
    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)

    specific_shuffle_update_key = "eval_input_configs:eval_2:shuffle"
    is_valid_input_config_key, key_name, input_name, field_name = (
        config_util.check_and_parse_input_config_key(
            configs, specific_shuffle_update_key))
    self.assertTrue(is_valid_input_config_key)
    self.assertEqual(key_name, "eval_input_configs")
    self.assertEqual(input_name, "eval_2")
    self.assertEqual(field_name, "shuffle")

    legacy_shuffle_update_key = "eval_shuffle"
    is_valid_input_config_key, key_name, input_name, field_name = (
        config_util.check_and_parse_input_config_key(configs,
                                                     legacy_shuffle_update_key))
    self.assertTrue(is_valid_input_config_key)
    self.assertEqual(key_name, "eval_input_configs")
    self.assertEqual(input_name, None)
    self.assertEqual(field_name, "shuffle")

    non_input_config_update_key = "label_map_path"
    is_valid_input_config_key, key_name, input_name, field_name = (
        config_util.check_and_parse_input_config_key(
            configs, non_input_config_update_key))
    self.assertFalse(is_valid_input_config_key)
    self.assertEqual(key_name, None)
    self.assertEqual(input_name, None)
    self.assertEqual(field_name, "label_map_path")

    with self.assertRaisesRegexp(ValueError,
                                 "Invalid key format when overriding configs."):
      config_util.check_and_parse_input_config_key(
          configs, "train_input_config:shuffle")

    with self.assertRaisesRegexp(
        ValueError, "Invalid key_name when overriding input config."):
      config_util.check_and_parse_input_config_key(
          configs, "invalid_key_name:train_name:shuffle")

    with self.assertRaisesRegexp(
        ValueError, "Invalid input_name when overriding input config."):
      config_util.check_and_parse_input_config_key(
          configs, "eval_input_configs:unknown_eval_name:shuffle")

    with self.assertRaisesRegexp(
        ValueError, "Invalid field_name when overriding input config."):
      config_util.check_and_parse_input_config_key(
          configs, "eval_input_configs:eval_2:unknown_field_name") 
Example #6
Source File: config_util_test.py    From multilabel-image-classification-tensorflow with MIT License 4 votes vote down vote up
def testCheckAndParseInputConfigKey(self):
    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")
    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    pipeline_config.eval_input_reader.add().name = "eval_1"
    pipeline_config.eval_input_reader.add().name = "eval_2"
    _write_config(pipeline_config, pipeline_config_path)
    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)

    specific_shuffle_update_key = "eval_input_configs:eval_2:shuffle"
    is_valid_input_config_key, key_name, input_name, field_name = (
        config_util.check_and_parse_input_config_key(
            configs, specific_shuffle_update_key))
    self.assertTrue(is_valid_input_config_key)
    self.assertEqual(key_name, "eval_input_configs")
    self.assertEqual(input_name, "eval_2")
    self.assertEqual(field_name, "shuffle")

    legacy_shuffle_update_key = "eval_shuffle"
    is_valid_input_config_key, key_name, input_name, field_name = (
        config_util.check_and_parse_input_config_key(configs,
                                                     legacy_shuffle_update_key))
    self.assertTrue(is_valid_input_config_key)
    self.assertEqual(key_name, "eval_input_configs")
    self.assertEqual(input_name, None)
    self.assertEqual(field_name, "shuffle")

    non_input_config_update_key = "label_map_path"
    is_valid_input_config_key, key_name, input_name, field_name = (
        config_util.check_and_parse_input_config_key(
            configs, non_input_config_update_key))
    self.assertFalse(is_valid_input_config_key)
    self.assertEqual(key_name, None)
    self.assertEqual(input_name, None)
    self.assertEqual(field_name, "label_map_path")

    with self.assertRaisesRegexp(ValueError,
                                 "Invalid key format when overriding configs."):
      config_util.check_and_parse_input_config_key(
          configs, "train_input_config:shuffle")

    with self.assertRaisesRegexp(
        ValueError, "Invalid key_name when overriding input config."):
      config_util.check_and_parse_input_config_key(
          configs, "invalid_key_name:train_name:shuffle")

    with self.assertRaisesRegexp(
        ValueError, "Invalid input_name when overriding input config."):
      config_util.check_and_parse_input_config_key(
          configs, "eval_input_configs:unknown_eval_name:shuffle")

    with self.assertRaisesRegexp(
        ValueError, "Invalid field_name when overriding input config."):
      config_util.check_and_parse_input_config_key(
          configs, "eval_input_configs:eval_2:unknown_field_name")