def setup(config_file='config.yml', default=False, training=False, prediction=False):
    """CLI interface to set up the training or prediction session.

    Takes as input the configuration file path (minus the '.py' extension)
    and arguments parse from CLI.
    """
    
    conf = yaml.load(open(config_file, 'r'), Loader=yaml.FullLoader)
    
    if training:
        session_type = 'training'
    elif prediction:
        session_type = 'prediction'
    else:
        message = '(t)raining or (p)rediction? (t/p) '
        session_type = {'t': 'training', 'p': 'prediction'}[select_option(['t', 'p'], message)]
    if default:
        all_default = 'y'
    else:
        all_default = select_bool('Default options for everything?')
    
    if all_default:
        generator = conf['default']['generator']
        if session_type == 'prediction':
            dataset = conf['default']['test_set']
            conf['generators'][generator] = get_config_from_weights(
                conf['weights_paths']['generator'], conf['generators'][generator], generator
            )
        elif session_type == 'training':
            dataset = conf['default']['training_set']
        
        return session_type, generator, conf, dataset
    
    logger.info('Select SR (generator) network')
    generators = {}
    for i, gen in enumerate(conf['generators']):
        generators[str(i)] = gen
        logger.info('{}: {}'.format(i, gen))
    generator = generators[select_option(generators)]
    
    load_weights = input('Load pretrained weights for {}? ([y]/n/d) '.format(generator))
    if load_weights == 'n':
        default = select_bool('Load default parameters for {}?'.format(generator))
        if not default:
            for param in conf['generators'][generator]:
                value = select_positive_integer(message='{}:'.format(param))
                conf['generators'][generator][param] = value
        else:
            logger.info('Default {} parameters.'.format(generator))
    elif (load_weights == 'd') and (conf['weights_paths']['generator']):
        logger.info('Loading default weights for {}'.format(generator))
        logger.info(conf['weights_paths']['generator'])
        conf['generators'][generator] = get_config_from_weights(
            conf['weights_paths']['generator'], conf['generators'][generator], generator
        )
    else:
        conf['weights_paths']['generator'] = browse_weights(conf['dirs']['weights'], generator)
        conf['generators']['generator'] = get_config_from_weights(
            conf['weights_paths']['generator'], conf['generators'][generator], generator
        )
    logger.info('{} parameters:'.format(generator))
    logger.info(conf['generators'][generator])
    
    if session_type == 'training':
        default_loss_weights = select_bool('Use default weights for loss components?')
        if not default_loss_weights:
            conf['loss_weights']['generator'] = select_positive_float(
                'Input coefficient for pixel-wise generator loss component '
            )
        use_discr = select_bool('Use an Adversarial Network?')
        if use_discr:
            conf['default']['discriminator'] = True
            discr_w = select_bool('Use pretrained discriminator weights?')
            if discr_w:
                conf['weights_paths']['discriminator'] = browse_weights(
                    conf['dirs']['weights'], 'discriminator'
                )
            if not default_loss_weights:
                conf['loss_weights']['discriminator'] = select_positive_float(
                    'Input coefficient for Adversarial loss component '
                )
        
        use_feature_extractor = select_bool('Use feature extractor?')
        if use_feature_extractor:
            conf['default']['feature_extractor'] = True
            if not default_loss_weights:
                conf['loss_weights']['feature_extractor'] = select_positive_float(
                    'Input coefficient for conv features loss component '
                )
        default_metrics = select_bool('Monitor default metrics?')
        if not default_metrics:
            suggested_list = suggest_metrics(use_discr, use_feature_extractor)
            selected_metrics = select_multiple_options(
                list(suggested_list.keys()), message='Select metrics to monitor.'
            )
            
            conf['session']['training']['monitored_metrics'] = {}
            for metric in selected_metrics:
                conf['session']['training']['monitored_metrics'][metric] = suggested_list[metric]
            print(conf['session']['training']['monitored_metrics'])
    
    dataset = select_dataset(session_type, conf)
    
    return session_type, generator, conf, dataset
CLI interface to set up the training or prediction session.

Takes as input the configuration file path (minus the '.py' extension)
and arguments parse from CLI.
ISR/utils/utils.py