当前位置: 首页>>代码示例>>Python>>正文


Python config_util.get_configs_from_pipeline_file方法代码示例

本文整理汇总了Python中object_detection.utils.config_util.get_configs_from_pipeline_file方法的典型用法代码示例。如果您正苦于以下问题:Python config_util.get_configs_from_pipeline_file方法的具体用法?Python config_util.get_configs_from_pipeline_file怎么用?Python config_util.get_configs_from_pipeline_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在object_detection.utils.config_util的用法示例。


在下文中一共展示了config_util.get_configs_from_pipeline_file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testUpdateMaskTypeForAllInputConfigs

# 需要导入模块: from object_detection.utils import config_util [as 别名]
# 或者: from object_detection.utils.config_util import get_configs_from_pipeline_file [as 别名]
def testUpdateMaskTypeForAllInputConfigs(self):
    original_mask_type = input_reader_pb2.NUMERICAL_MASKS
    new_mask_type = input_reader_pb2.PNG_MASKS

    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")
    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    train_config = pipeline_config.train_input_reader
    train_config.mask_type = original_mask_type
    eval_1 = pipeline_config.eval_input_reader.add()
    eval_1.mask_type = original_mask_type
    eval_1.name = "eval_1"
    eval_2 = pipeline_config.eval_input_reader.add()
    eval_2.mask_type = original_mask_type
    eval_2.name = "eval_2"
    _write_config(pipeline_config, pipeline_config_path)

    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)
    override_dict = {"mask_type": new_mask_type}
    configs = config_util.merge_external_params_with_configs(
        configs, kwargs_dict=override_dict)

    self.assertEqual(configs["train_input_config"].mask_type, new_mask_type)
    for eval_input_config in configs["eval_input_configs"]:
      self.assertEqual(eval_input_config.mask_type, new_mask_type) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:26,代码来源:config_util_test.py

示例2: test_get_configs_from_pipeline_file

# 需要导入模块: from object_detection.utils import config_util [as 别名]
# 或者: from object_detection.utils.config_util import get_configs_from_pipeline_file [as 别名]
def test_get_configs_from_pipeline_file(self):
    """Test that proto configs can be read from pipeline config file."""
    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")

    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    pipeline_config.model.faster_rcnn.num_classes = 10
    pipeline_config.train_config.batch_size = 32
    pipeline_config.train_input_reader.label_map_path = "path/to/label_map"
    pipeline_config.eval_config.num_examples = 20
    pipeline_config.eval_input_reader.add().queue_capacity = 100

    _write_config(pipeline_config, pipeline_config_path)

    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)
    self.assertProtoEquals(pipeline_config.model, configs["model"])
    self.assertProtoEquals(pipeline_config.train_config,
                           configs["train_config"])
    self.assertProtoEquals(pipeline_config.train_input_reader,
                           configs["train_input_config"])
    self.assertProtoEquals(pipeline_config.eval_config,
                           configs["eval_config"])
    self.assertProtoEquals(pipeline_config.eval_input_reader,
                           configs["eval_input_configs"]) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:25,代码来源:config_util_test.py

示例3: test_create_pipeline_proto_from_configs

# 需要导入模块: from object_detection.utils import config_util [as 别名]
# 或者: from object_detection.utils.config_util import get_configs_from_pipeline_file [as 别名]
def test_create_pipeline_proto_from_configs(self):
    """Tests that proto can be reconstructed from configs dictionary."""
    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")

    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    pipeline_config.model.faster_rcnn.num_classes = 10
    pipeline_config.train_config.batch_size = 32
    pipeline_config.train_input_reader.label_map_path = "path/to/label_map"
    pipeline_config.eval_config.num_examples = 20
    pipeline_config.eval_input_reader.add().queue_capacity = 100
    _write_config(pipeline_config, pipeline_config_path)

    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)
    pipeline_config_reconstructed = (
        config_util.create_pipeline_proto_from_configs(configs))
    self.assertEqual(pipeline_config, pipeline_config_reconstructed) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:18,代码来源:config_util_test.py

示例4: test_save_pipeline_config

# 需要导入模块: from object_detection.utils import config_util [as 别名]
# 或者: from object_detection.utils.config_util import get_configs_from_pipeline_file [as 别名]
def test_save_pipeline_config(self):
    """Tests that the pipeline config is properly saved to disk."""
    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    pipeline_config.model.faster_rcnn.num_classes = 10
    pipeline_config.train_config.batch_size = 32
    pipeline_config.train_input_reader.label_map_path = "path/to/label_map"
    pipeline_config.eval_config.num_examples = 20
    pipeline_config.eval_input_reader.add().queue_capacity = 100

    config_util.save_pipeline_config(pipeline_config, self.get_temp_dir())
    configs = config_util.get_configs_from_pipeline_file(
        os.path.join(self.get_temp_dir(), "pipeline.config"))
    pipeline_config_reconstructed = (
        config_util.create_pipeline_proto_from_configs(configs))

    self.assertEqual(pipeline_config, pipeline_config_reconstructed) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:18,代码来源:config_util_test.py

示例5: testNewMomentumOptimizerValue

# 需要导入模块: from object_detection.utils import config_util [as 别名]
# 或者: from object_detection.utils.config_util import get_configs_from_pipeline_file [as 别名]
def testNewMomentumOptimizerValue(self):
    """Tests that new momentum value is updated appropriately."""
    original_momentum_value = 0.4
    hparams = tf.contrib.training.HParams(momentum_optimizer_value=1.1)
    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")

    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    optimizer_config = pipeline_config.train_config.optimizer.rms_prop_optimizer
    optimizer_config.momentum_optimizer_value = original_momentum_value
    _write_config(pipeline_config, pipeline_config_path)

    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)
    configs = config_util.merge_external_params_with_configs(configs, hparams)
    optimizer_config = configs["train_config"].optimizer.rms_prop_optimizer
    new_momentum_value = optimizer_config.momentum_optimizer_value
    self.assertAlmostEqual(1.0, new_momentum_value)  # Clipped to 1.0. 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:18,代码来源:config_util_test.py

示例6: testNewClassificationLocalizationWeightRatio

# 需要导入模块: from object_detection.utils import config_util [as 别名]
# 或者: from object_detection.utils.config_util import get_configs_from_pipeline_file [as 别名]
def testNewClassificationLocalizationWeightRatio(self):
    """Tests that the loss weight ratio is updated appropriately."""
    original_localization_weight = 0.1
    original_classification_weight = 0.2
    new_weight_ratio = 5.0
    hparams = tf.contrib.training.HParams(
        classification_localization_weight_ratio=new_weight_ratio)
    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")

    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    pipeline_config.model.ssd.loss.localization_weight = (
        original_localization_weight)
    pipeline_config.model.ssd.loss.classification_weight = (
        original_classification_weight)
    _write_config(pipeline_config, pipeline_config_path)

    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)
    configs = config_util.merge_external_params_with_configs(configs, hparams)
    loss = configs["model"].ssd.loss
    self.assertAlmostEqual(1.0, loss.localization_weight)
    self.assertAlmostEqual(new_weight_ratio, loss.classification_weight) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:23,代码来源:config_util_test.py

示例7: testNewFocalLossParameters

# 需要导入模块: from object_detection.utils import config_util [as 别名]
# 或者: from object_detection.utils.config_util import get_configs_from_pipeline_file [as 别名]
def testNewFocalLossParameters(self):
    """Tests that the loss weight ratio is updated appropriately."""
    original_alpha = 1.0
    original_gamma = 1.0
    new_alpha = 0.3
    new_gamma = 2.0
    hparams = tf.contrib.training.HParams(
        focal_loss_alpha=new_alpha, focal_loss_gamma=new_gamma)
    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")

    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    classification_loss = pipeline_config.model.ssd.loss.classification_loss
    classification_loss.weighted_sigmoid_focal.alpha = original_alpha
    classification_loss.weighted_sigmoid_focal.gamma = original_gamma
    _write_config(pipeline_config, pipeline_config_path)

    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)
    configs = config_util.merge_external_params_with_configs(configs, hparams)
    classification_loss = configs["model"].ssd.loss.classification_loss
    self.assertAlmostEqual(new_alpha,
                           classification_loss.weighted_sigmoid_focal.alpha)
    self.assertAlmostEqual(new_gamma,
                           classification_loss.weighted_sigmoid_focal.gamma) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:25,代码来源:config_util_test.py

示例8: testNewTrainInputPath

# 需要导入模块: from object_detection.utils import config_util [as 别名]
# 或者: from object_detection.utils.config_util import get_configs_from_pipeline_file [as 别名]
def testNewTrainInputPath(self):
    """Tests that train input path can be overwritten with single file."""
    original_train_path = ["path/to/data"]
    new_train_path = "another/path/to/data"
    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")

    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    reader_config = pipeline_config.train_input_reader.tf_record_input_reader
    reader_config.input_path.extend(original_train_path)
    _write_config(pipeline_config, pipeline_config_path)

    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)
    override_dict = {"train_input_path": new_train_path}
    configs = config_util.merge_external_params_with_configs(
        configs, kwargs_dict=override_dict)
    reader_config = configs["train_input_config"].tf_record_input_reader
    final_path = reader_config.input_path
    self.assertEqual([new_train_path], final_path) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:20,代码来源:config_util_test.py

示例9: testNewTrainInputPathList

# 需要导入模块: from object_detection.utils import config_util [as 别名]
# 或者: from object_detection.utils.config_util import get_configs_from_pipeline_file [as 别名]
def testNewTrainInputPathList(self):
    """Tests that train input path can be overwritten with multiple files."""
    original_train_path = ["path/to/data"]
    new_train_path = ["another/path/to/data", "yet/another/path/to/data"]
    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")

    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    reader_config = pipeline_config.train_input_reader.tf_record_input_reader
    reader_config.input_path.extend(original_train_path)
    _write_config(pipeline_config, pipeline_config_path)

    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)
    override_dict = {"train_input_path": new_train_path}
    configs = config_util.merge_external_params_with_configs(
        configs, kwargs_dict=override_dict)
    reader_config = configs["train_input_config"].tf_record_input_reader
    final_path = reader_config.input_path
    self.assertEqual(new_train_path, final_path) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:20,代码来源:config_util_test.py

示例10: testNewLabelMapPath

# 需要导入模块: from object_detection.utils import config_util [as 别名]
# 或者: from object_detection.utils.config_util import get_configs_from_pipeline_file [as 别名]
def testNewLabelMapPath(self):
    """Tests that label map path can be overwritten in input readers."""
    original_label_map_path = "path/to/original/label_map"
    new_label_map_path = "path//to/new/label_map"
    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")

    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    train_input_reader = pipeline_config.train_input_reader
    train_input_reader.label_map_path = original_label_map_path
    eval_input_reader = pipeline_config.eval_input_reader.add()
    eval_input_reader.label_map_path = original_label_map_path
    _write_config(pipeline_config, pipeline_config_path)

    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)
    override_dict = {"label_map_path": new_label_map_path}
    configs = config_util.merge_external_params_with_configs(
        configs, kwargs_dict=override_dict)
    self.assertEqual(new_label_map_path,
                     configs["train_input_config"].label_map_path)
    for eval_input_config in configs["eval_input_configs"]:
      self.assertEqual(new_label_map_path, eval_input_config.label_map_path) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:23,代码来源:config_util_test.py

示例11: testDontOverwriteEmptyLabelMapPath

# 需要导入模块: from object_detection.utils import config_util [as 别名]
# 或者: from object_detection.utils.config_util import get_configs_from_pipeline_file [as 别名]
def testDontOverwriteEmptyLabelMapPath(self):
    """Tests that label map path will not by overwritten with empty string."""
    original_label_map_path = "path/to/original/label_map"
    new_label_map_path = ""
    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")

    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    train_input_reader = pipeline_config.train_input_reader
    train_input_reader.label_map_path = original_label_map_path
    eval_input_reader = pipeline_config.eval_input_reader.add()
    eval_input_reader.label_map_path = original_label_map_path
    _write_config(pipeline_config, pipeline_config_path)

    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)
    override_dict = {"label_map_path": new_label_map_path}
    configs = config_util.merge_external_params_with_configs(
        configs, kwargs_dict=override_dict)
    self.assertEqual(original_label_map_path,
                     configs["train_input_config"].label_map_path)
    self.assertEqual(original_label_map_path,
                     configs["eval_input_configs"][0].label_map_path) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:23,代码来源:config_util_test.py

示例12: testTrainShuffle

# 需要导入模块: from object_detection.utils import config_util [as 别名]
# 或者: from object_detection.utils.config_util import get_configs_from_pipeline_file [as 别名]
def testTrainShuffle(self):
    """Tests that `train_shuffle` keyword arguments are applied correctly."""
    original_shuffle = True
    desired_shuffle = False

    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")
    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    pipeline_config.train_input_reader.shuffle = original_shuffle
    _write_config(pipeline_config, pipeline_config_path)

    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)
    override_dict = {"train_shuffle": desired_shuffle}
    configs = config_util.merge_external_params_with_configs(
        configs, kwargs_dict=override_dict)
    train_shuffle = configs["train_input_config"].shuffle
    self.assertEqual(desired_shuffle, train_shuffle) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:18,代码来源:config_util_test.py

示例13: testOverWriteRetainOriginalImages

# 需要导入模块: from object_detection.utils import config_util [as 别名]
# 或者: from object_detection.utils.config_util import get_configs_from_pipeline_file [as 别名]
def testOverWriteRetainOriginalImages(self):
    """Tests that `train_shuffle` keyword arguments are applied correctly."""
    original_retain_original_images = True
    desired_retain_original_images = False

    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")
    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    pipeline_config.eval_config.retain_original_images = (
        original_retain_original_images)
    _write_config(pipeline_config, pipeline_config_path)

    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)
    override_dict = {
        "retain_original_images_in_eval": desired_retain_original_images
    }
    configs = config_util.merge_external_params_with_configs(
        configs, kwargs_dict=override_dict)
    retain_original_images = configs["eval_config"].retain_original_images
    self.assertEqual(desired_retain_original_images, retain_original_images) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:21,代码来源:config_util_test.py

示例14: testOverwriteAllEvalSampling

# 需要导入模块: from object_detection.utils import config_util [as 别名]
# 或者: from object_detection.utils.config_util import get_configs_from_pipeline_file [as 别名]
def testOverwriteAllEvalSampling(self):
    original_num_eval_examples = 1
    new_num_eval_examples = 10

    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")
    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    pipeline_config.eval_input_reader.add().sample_1_of_n_examples = (
        original_num_eval_examples)
    pipeline_config.eval_input_reader.add().sample_1_of_n_examples = (
        original_num_eval_examples)
    _write_config(pipeline_config, pipeline_config_path)

    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)
    override_dict = {"sample_1_of_n_eval_examples": new_num_eval_examples}
    configs = config_util.merge_external_params_with_configs(
        configs, kwargs_dict=override_dict)
    for eval_input_config in configs["eval_input_configs"]:
      self.assertEqual(new_num_eval_examples,
                       eval_input_config.sample_1_of_n_examples) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:21,代码来源:config_util_test.py

示例15: testErrorOverwritingMultipleInputConfig

# 需要导入模块: from object_detection.utils import config_util [as 别名]
# 或者: from object_detection.utils.config_util import get_configs_from_pipeline_file [as 别名]
def testErrorOverwritingMultipleInputConfig(self):
    original_shuffle = False
    new_shuffle = True
    pipeline_config_path = os.path.join(self.get_temp_dir(), "pipeline.config")
    pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
    eval_1 = pipeline_config.eval_input_reader.add()
    eval_1.shuffle = original_shuffle
    eval_1.name = "eval_1"
    eval_2 = pipeline_config.eval_input_reader.add()
    eval_2.shuffle = original_shuffle
    eval_2.name = "eval_2"
    _write_config(pipeline_config, pipeline_config_path)

    configs = config_util.get_configs_from_pipeline_file(pipeline_config_path)
    override_dict = {"eval_shuffle": new_shuffle}
    with self.assertRaises(ValueError):
      configs = config_util.merge_external_params_with_configs(
          configs, kwargs_dict=override_dict) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:20,代码来源:config_util_test.py


注:本文中的object_detection.utils.config_util.get_configs_from_pipeline_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。