birl.bm_template module¶
All other benchmarks should be deviated this way so the core functionality of the benchmarks such as loading or evaluation is not overwritten
INSTALLATION:
- …
Sample run:
mkdir ./results
touch sample-config.yaml
python birl/bm_template.py -t ./data_images/pairs-imgs-lnds_histol.csv -d ./data_images -o ./results --visual --unique -cfg ./sample-config.yaml
Copyright (C) 2017-2019 Jiri Borovec <jiri.borovec@fel.cvut.cz>
-
class
birl.bm_template.
BmTemplate
(params)[source]¶ Bases:
birl.benchmark.ImRegBenchmark
Basic template showing utilization by inheriting general workflow. This case serves as an example of using the general image regist. benchmark.
Parameters: params (dict) – dictionary with experiment configuration, the required options are names in REQUIRED_PARAMS, note that the basic parameters are inherited General methods that should be overwritten:
- _check_required_params
- _prepare_img_registration
- _execute_img_registration/_generate_regist_command
- _extract_warped_image_landmarks
- _extract_execution_time
- _clear_after_registration
Note
The actual implementation simulates the “WORSE” registration while it blindly copies the moving landmarks as results of the registration. It also copies the moving images so there is correct “warping” between image and landmarks. It means that there was no registration performed.
Examples
>>> # Running in single thread: >>> from birl.utilities.data_io import create_folder, update_path >>> path_out = create_folder('temp_results') >>> path_csv = os.path.join(update_path('data_images'), 'pairs-imgs-lnds_mix.csv') >>> open('sample_config.yaml', 'w').close() >>> BmTemplate.main({ ... 'path_table': path_csv, ... 'path_out': path_out, ... 'nb_workers': 1, ... 'unique': False, ... 'visual': True, ... 'path_config': 'sample_config.yaml' ... }) # doctest: +ELLIPSIS ({...}, '...BmTemplate') >>> import shutil >>> shutil.rmtree(path_out, ignore_errors=True) >>> os.remove('sample_config.yaml')
>>> # Running in multiple parallel threads: >>> from birl.utilities.data_io import create_folder, update_path >>> path_out = create_folder('temp_results') >>> path_csv = os.path.join(update_path('data_images'), 'pairs-imgs-lnds_mix.csv') >>> params = {'path_table': path_csv, ... 'path_out': path_out, ... 'nb_workers': 2, ... 'unique': False, ... 'visual': True, ... 'path_config': ''} >>> benchmark = BmTemplate(params) >>> benchmark.run() True >>> del benchmark >>> import shutil >>> shutil.rmtree(path_out, ignore_errors=True)
initialise benchmark
Parameters: params (dict) – parameters -
_clear_after_registration
(item)[source]¶ clean unnecessarily files after the registration
Parameters: item (dict) – dictionary with regist. information Return dict: the same or updated regist. info
-
_extract_execution_time
(item)[source]¶ if needed update the execution time
Parameters: item (dict) – dictionary with registration params Return float|None: time in minutes
-
_extract_warped_image_landmarks
(item)[source]¶ get registration results - warped registered images and landmarks
Parameters: item (dict) – dictionary with registration params Return dict: paths to warped images/landmarks
-
_generate_regist_command
(item)[source]¶ generate the registration command(s)
Parameters: item (dict) – dictionary with registration params Return str|list(str): the execution commands
-
_prepare_img_registration
(item)[source]¶ prepare the experiment folder if it is required, eq. copy some extra files
Parameters: item (dict) – dictionary with regist. params Return dict: the same or updated registration info