diff --git a/color_map.conf b/color_map.conf index 7399535ff5bca364e7d833bda418bb37d466505a..5bda62bd4438c80d5e5c8dd179f8a1761a669c6d 100644 --- a/color_map.conf +++ b/color_map.conf @@ -48,8 +48,15 @@ 22=(220,20,60) #reference_list_title - #b8860b 23=(184,134,11) + #main_paragraph - #ff1493 -24=(255,20,147) +#moved to alias +#24=(255,20,147) + +[color_alias] +# aliases are processed within the preprocessing step +#main_paragraph - almost same as section_paragraph +24=(128,0,128) [color_labels] 1=abstract @@ -75,5 +82,5 @@ 21=acknowledgement 22=reference 23=reference_list_title -24=main_paragraph +# 24=main_paragraph diff --git a/color_map_selected.conf b/color_map_selected.conf index d90951e058caa1c8460883fee3608896bd57d0f3..ee129aee155f8127f73c6deb7e7734fadcd6bfd4 100644 --- a/color_map_selected.conf +++ b/color_map_selected.conf @@ -48,8 +48,15 @@ #22=(220,20,60) #reference_list_title - #b8860b #23=(184,134,11) + #main_paragraph - #ff1493 -24=(255,20,147) +#moved to alias +#24=(255,20,147) + +[color_alias] +# aliases are processed within the preprocessing step +#main_paragraph - almost same as section_paragraph +24=(128,0,128) [color_labels] 1=abstract @@ -75,5 +82,4 @@ #21=acknowledgement #22=reference #23=reference_list_title -24=main_paragraph - +#24=main_paragraph diff --git a/sciencebeam_gym/trainer/preprocess.py b/sciencebeam_gym/trainer/preprocess.py index 686e1051a7570f25681ed188c22c990eedd59929..0a2f2d15a5fb866ea95698a1c303148cf1baab1e 100644 --- a/sciencebeam_gym/trainer/preprocess.py +++ b/sciencebeam_gym/trainer/preprocess.py @@ -43,7 +43,9 @@ slim = tf.contrib.slim error_count = Metrics.counter('main', 'errorCount') -def parse_color_map(f): +def parse_color_map(f, section_names=None): + if section_names is None: + section_names = ['color_map'] color_map_config = ConfigParser() color_map_config.readfp(f) @@ -62,8 +64,10 @@ def parse_color_map(f): raise Exception('invalid color value: {}'.format(s)) color_map = dict() - for k, v in color_map_config.items('color_map'): - color_map[parse_color(k)] = parse_color(v) + for section_name in section_names: + if color_map_config.has_section(section_name): + for k, v in color_map_config.items(section_name): + color_map[parse_color(k)] = parse_color(v) return color_map def map_colors(img, color_map): @@ -198,7 +202,7 @@ def configure_pipeline(p, opt): color_map = None if opt.color_map: with file_io.FileIO(opt.color_map, 'r') as config_f: - color_map = parse_color_map(config_f) + color_map = parse_color_map(config_f, section_names=['color_alias', 'color_map']) if color_map: logger.info('read {} color mappings'.format(len(color_map))) else: