def test_load_arch_defs(self): """Test arch def str-to-dict conversion compatible with merging""" default_cfg = GeneralizedRCNNRunner().get_default_cfg() cfg = default_cfg.clone() cfg.merge_from_file(get_resource_path("arch_def_merging.yaml")) with make_temp_directory("detectron2go_tmp") as tmp_dir: # Dump out config with arch def file_name = os.path.join(tmp_dir, "test_archdef_config.yaml") with open(file_name, "w") as f: f.write(cfg.dump()) # Attempt to reload the config another_cfg = default_cfg.clone() another_cfg.merge_from_file(file_name)
def test_base_reroute(self): default_cfg = GeneralizedRCNNRunner().get_default_cfg() # use rerouted file as base cfg = default_cfg.clone() cfg.merge_from_file(get_resource_path("rerouted_base.yaml")) self.assertEqual(cfg.MODEL.MASK_ON, True) # base is loaded self.assertEqual(cfg.MODEL.FBNET_V2.ARCH, "test") # non-base is loaded # use multiple files as base cfg = default_cfg.clone() cfg.merge_from_file(get_resource_path("rerouted_multi_base.yaml")) self.assertEqual(cfg.MODEL.MASK_ON, True) # base is loaded self.assertEqual(cfg.MODEL.FBNET_V2.ARCH, "FBNetV3_A") # second base is loaded self.assertEqual(cfg.OUTPUT_DIR, "test") # non-base is loaded
def test_default_cfg_dump_and_load(self): default_cfg = GeneralizedRCNNRunner().get_default_cfg() cfg = default_cfg.clone() with make_temp_directory("detectron2go_tmp") as tmp_dir: file_name = os.path.join(tmp_dir, "config.yaml") # this is same as the one in fblearner_launch_utils_detectron2go.py with open(file_name, "w") as f: f.write(cfg.dump(default_flow_style=False)) # check if the dumped config file can be merged cfg.merge_from_file(file_name)