def main(): logger.remove() logger.add(stdout, format='{level} | [{time:HH:mm:ss}] {name} -- {message}.', level='INFO', filter=lambda record: record['extra']['indent'] == 1) logger.add(stdout, format=' {level} | [{time:HH:mm:ss}] {name} -- {message}.', level='INFO', filter=lambda record: record['extra']['indent'] == 2) main_logger = logger.bind(indent=1) args = get_argument_parser().parse_args() if not args.verbose: main_logger.info('Verbose if off. Not logging messages') logger.disable('__main__') logger.disable('processes') main_logger.info(datetime.now().strftime('%Y-%m-%d %H:%M')) main_logger.info('Loading settings') settings_dataset = load_settings_file(args.config_file_dataset) settings_features = load_settings_file(args.config_file_features) main_logger.info('Settings loaded') if settings_dataset['workflow']['create_dataset']: main_logger.info('Starting Clotho dataset creation') create_dataset(settings_dataset) main_logger.info('Dataset created') if settings_dataset['workflow']['extract_features']: main_logger.info('Starting Clotho feature extraction') extract_features(settings_dataset, settings_features) main_logger.info('Features extracted')
def do_process(settings_path=None, settings=None, use_tf=False): """The process of the experiment for the proposed method. :param settings_path: The path for the settings. :type settings_path: str|None :param settings: The settings to be used. :type settings: dict|None :param use_tf: Do we use teacher forcing? :type use_tf: bool :param use_tf: Do we use teacher forcing? :type use_tf: bool """ if settings_path is not None: settings = load_settings_file(settings_path) model = TFCRNN if use_tf else CRNN if not use_tf: print_msg('Baseline experiment') print_msg('Starting experiment with folds', end='\n\n') p_print = partial(print_msg, decorate_prv='*', decorate_nxt='*', end='\n\n') for i in range(2, 4): settings['data_loader'].update({'data_fold': i + 1}) p_print('Fold {}'.format(i + 1)) experiment(settings, model, use_tf=use_tf)
def main(): # Treat the logging. logger.remove() logger.add(stdout, format='{level} | [{time:HH:mm:ss}] {name} -- {message}.', level='INFO', filter=lambda record: record['extra']['indent'] == 1) logger.add(stdout, format=' {level} | [{time:HH:mm:ss}] {name} -- {message}.', level='INFO', filter=lambda record: record['extra']['indent'] == 2) main_logger = logger.bind(indent=1) args = get_argument_parser().parse_args() main_logger.info('Doing only dataset creation') # Check for verbosity. if not args.verbose: main_logger.info('Verbose if off. Not logging messages') logger.disable('__main__') logger.disable('processes') main_logger.info(datetime.now().strftime('%Y-%m-%d %H:%M')) # Load settings file. main_logger.info('Loading settings') settings = load_settings_file(args.config_file_dataset) main_logger.info('Settings loaded') # Create the dataset. main_logger.info('Starting Clotho dataset creation') create_dataset(settings) main_logger.info('Dataset created')
def do_process(settings_path=None, settings=None): """The process of the baseline experiment. :param settings_path: The path for the settings. :type settings_path: str|None :param settings: The settings. :type settings: dict|None """ if settings_path is not None: settings = load_settings_file(settings_path) print_msg('Starting baseline experiment', end='\n\n') experiment(settings, CRNN)
def main(): """Main entry point for the project. """ print_date_and_time() arg_parser = get_argument_parser() args = arg_parser.parse_args() experiment_process = baseline if args.baseline else tf_process settings = load_settings_file(args.config_file) print_yaml_settings(settings) experiment_process(settings=settings)
def main(): """Main entry point for the project. """ print_date_and_time() arg_parser = get_argument_parser() args = arg_parser.parse_args() settings = load_settings_file(args.config_file) print_yaml_settings(settings) experiment_process = with_folds_process if settings['global']['has_folds'] \ else no_folds_process experiment_process(settings=settings, use_tf=not args.baseline)
def main(): args = get_argument_parser().parse_args() model_to_use = args.model config_file = args.config_file file_ext = args.file_ext settings_dir = args.file_dir date_and_time() with InformAboutProcess('Loading settings'): settings = load_settings_file( file_name=Path(f'{config_file}{file_ext}'), settings_dir=Path(settings_dir)) do_process(settings_path=None, settings=settings, model_to_use=model_to_use)
def do_process(settings_path=None, settings=None): """The process of the experiment for the proposed method. :param settings_path: The path for the settings. :type settings_path: str|None :param settings: The settings to be used. :type settings: dict|None """ if settings_path is not None: settings = load_settings_file(settings_path) print_msg('Starting teacher forcing experiment', end='\n\n') p_print = partial(print_msg, decorate_prv='*', decorate_nxt='*', end='\n\n') for i in range(4): settings['data_loader'].update({'data_fold': i + 1}) p_print('Fold {}'.format(i + 1)) experiment(settings, TFCRNN)
def do_process(settings_path=None, settings=None, use_tf=False): """The process of the baseline experiment. :param settings_path: The path for the settings. :type settings_path: str|None :param settings: The settings. :type settings: dict|None :param use_tf: Do we use teacher forcing? :type use_tf: bool """ if settings_path is not None: settings = load_settings_file(settings_path) model = TFCRNN if use_tf else CRNN if not use_tf: print_msg('Baseline experiment') print_msg('Starting experiment without folds', end='\n\n') experiment(settings, model, use_tf=use_tf)
def do_process(settings_path: Optional[Union[Path, None]] = None, settings: Optional[Union[MutableMapping, None]] = None, model_to_use: Optional[Union[str, None]] = None) \ -> None: """The process of the baseline experiment. :param settings_path: Path for the settings. Defaults to None. :type settings_path: str|None, optional :param settings: Settings. Defaults to None. :type settings: dict|None, optional :param model_to_use: Model to use. Defaults to None. :type model_to_use: str, optional """ if settings_path is not None: settings = load_settings_file(Path(f'{settings_path}.yaml')) if model_to_use == 'baseline': msg = 'Baseline experiment' model = CRNN elif model_to_use == 'baseline_dilated': msg = 'Baseline with dilated convolutions experiment' model = BaselineDilated elif model_to_use == 'dessed': msg = 'Depth-wise separable with RNN experiment' model = DESSED elif model_to_use == 'dessed_dilated': msg = 'Depth-wise separable with dilated convolutions experiment' model = DESSEDDilated else: raise AttributeError(f'Unrecognized model `{model_to_use}`. ' f'Accepted model names are: `baseline`, ' '`baseline_dilated`, `dessed`, ' '`dessed_dilated`.') cmd_msg(msg, start='\n-- ') model_settings = settings[model_to_use] cmd_msg('Starting experiment', end='\n\n') experiment(settings=settings, model_settings=model_settings, model_class=model)