Skip to content

Commit

Permalink
Check validity of the config to avoid silent errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinzlocha authored May 9, 2019
1 parent 9560ed1 commit cf84dfd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions keras_retinanet/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
limitations under the License.
"""

import os
import configparser
import numpy as np
import keras
Expand All @@ -23,6 +24,14 @@
def read_config_file(config_path):
config = configparser.ConfigParser()
config.read(config_path)

assert os.path.isfile(config_path), "Could not find {}.".format(config_path)

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

assert {'sizes', 'strides', 'ratios', 'scales'} <= set(config['anchor_parameters']), \
"Malformed config file. Verify that it contains the following keys: sizes, strides, ratios and scales."

return config

Expand Down

0 comments on commit cf84dfd

Please sign in to comment.