1616import numpy as np
1717
1818from utils .yacs import Config
19+ from modules .basic_module import MODULE_DEPENDENCIES
1920
2021
2122class Pipeline :
@@ -47,11 +48,12 @@ def get_saturation_values(self):
4748
4849 # Saturation values should be carefully calculated if BLC module is activated
4950 if 'blc' in self .cfg .module_enable_status :
50- hdr_r_max_value = raw_max_value - self .cfg .blc .bl_r
51- hdr_b_max_value = raw_max_value - self .cfg .blc .bl_b
52- hdr_gr_max_value = int (raw_max_value - self .cfg .blc .bl_gr + hdr_r_max_value * self .cfg .blc .alpha / 1024 )
53- hdr_gb_max_value = int (raw_max_value - self .cfg .blc .bl_gb + hdr_b_max_value * self .cfg .blc .beta / 1024 )
54- hdr_max_value = max ([hdr_r_max_value , hdr_b_max_value , hdr_gr_max_value , hdr_gb_max_value ])
51+ blc = self .cfg .blc
52+ hdr_max_r = raw_max_value - blc .bl_r
53+ hdr_max_b = raw_max_value - blc .bl_b
54+ hdr_max_gr = int (raw_max_value - blc .bl_gr + hdr_max_r * blc .alpha / 1024 )
55+ hdr_max_gb = int (raw_max_value - blc .bl_gb + hdr_max_b * blc .beta / 1024 )
56+ hdr_max_value = max (hdr_max_r , hdr_max_b , hdr_max_gr , hdr_max_gb )
5557 else :
5658 hdr_max_value = raw_max_value
5759
@@ -73,10 +75,11 @@ def get_modules(self):
7375 module_cls = getattr (package , module_name .upper ())
7476 module = module_cls (self .cfg )
7577
76- if hasattr (module , 'dependent_modules' ):
77- for m in module .dependent_modules :
78- if m not in enabled_modules :
79- raise RuntimeError ('{} is available only if {} is activated' .format (module_name , m ))
78+ for m in MODULE_DEPENDENCIES .get (module_cls .__name__ , []):
79+ if m not in enabled_modules :
80+ raise RuntimeError (
81+ '{} is unavailable when {} is deactivated' .format (module_name , m )
82+ )
8083
8184 modules [module_name ] = module
8285
@@ -145,7 +148,7 @@ def run(self, raw_path, save_dir, load_raw_fn, suffix=''):
145148 """
146149 A higher level API that writes ISP result into disk
147150 :param raw_path: path to the raw file to be processed
148- :param save_dir: directory to save the output (the output will share the filename with input)
151+ :param save_dir: directory to save the output (shares the same filename as the input)
149152 :param load_raw_fn: function to load the Bayer array from the raw_path
150153 :param suffix: suffix to added to the output filename
151154 """
@@ -164,8 +167,8 @@ def batch_run(self, raw_paths, save_dirs, load_raw_fn, suffixes='', num_processe
164167 """
165168 Batch running with multiprocessing
166169 :param raw_paths: list of paths to the raw files to be executed
167- :param save_dirs: list of directories to save the outputs. If given a string, it will be copied
168- to a N-element list, where N is the number of paths in raw_paths
170+ :param save_dirs: list of directories to save the outputs. If given a string, it will be
171+ copied to a N-element list, where N is the number of paths in raw_paths
169172 :param load_raw_fn: function to load the Bayer array from the raw_path
170173 :param suffixes: a list of suffixes to added to the output filenames
171174 :param num_processes: number of processes in multiprocessing
0 commit comments