Skip to content

Commit

Permalink
Merge pull request fizyr#997 from martinzlocha/patch-1
Browse files Browse the repository at this point in the history
Check validity of the config to avoid silent errors.
  • Loading branch information
hgaiser authored Jun 6, 2019
2 parents 9560ed1 + 93b84c3 commit f9d7f69
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion keras_retinanet/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,18 @@

def read_config_file(config_path):
config = configparser.ConfigParser()
config.read(config_path)

with open(config_path, 'r') as file:
config.read_file(file)

assert 'anchor_parameters' in config, \
"Malformed config file. Verify that it contains the anchor_parameters section."

config_keys = set(config['anchor_parameters'])
default_keys = set(AnchorParameters.default.__dict__.keys())

assert config_keys <= default_keys, \
"Malformed config file. These keys are not valid: {}".format(config_keys - default_keys)

return config

Expand Down

0 comments on commit f9d7f69

Please sign in to comment.