Beispiel #1
0
def main():
    enable_gpu_if_possible()

    parser = argparse.ArgumentParser(description='Train networks.')

    parser.add_argument('-s',
                        '--simple',
                        action='store_true',
                        help='Train simple conv net.')
    parser.add_argument('-u',
                        '--unet',
                        action='store_true',
                        help='Train Unet net.')
    parser.add_argument('-g',
                        '--gan',
                        action='store_true',
                        help='Train GAN net.')
    parser.add_argument('training_name')

    args = parser.parse_args()

    if args.simple:
        train(Models.SIMPLE_CONV, args.training_name)
    if args.unet:
        train(Models.UNET, args.training_name)
    if args.gan:
        train(Models.GAN, args.training_name)
Beispiel #2
0
def main():
    enable_gpu_if_possible()

    parser = argparse.ArgumentParser(description='Train networks.')

    model_selection = parser.add_mutually_exclusive_group()
    model_selection.add_argument('-s',
                                 '--simple',
                                 action='store_true',
                                 help='Train simple conv net.')
    model_selection.add_argument('-u',
                                 '--unet',
                                 action='store_true',
                                 help='Train Unet et.')
    model_selection.add_argument('-g',
                                 '--gan',
                                 action='store_true',
                                 help='Train GAN net.')

    parser.add_argument('weights_path')
    parser.add_argument('output_dir')

    args = parser.parse_args()
    weights_path = Path(args.weights_path)
    output_dir = Path(args.output_dir)

    if args.simple:
        test(Models.SIMPLE_CONV, weights_path, output_dir)
    elif args.unet:
        test(Models.UNET, weights_path, output_dir)
    elif args.gan:
        test(Models.GAN, weights_path, output_dir)
def main():
    enable_gpu_if_possible()

    parser = argparse.ArgumentParser(
        description='Find best GAN weights in dir.')

    parser.add_argument('weights_dir_path')
    args = parser.parse_args()
    weights_dir_path = Path(args.weights_dir_path)

    find_best_gan(weights_dir_path)
def main():
    enable_gpu_if_possible()

    parser = argparse.ArgumentParser(description='Export Sentinel-2 dataset.')

    model_selection = parser.add_mutually_exclusive_group()
    model_selection.add_argument('-s', '--simple', action='store_true',
                                 help='Export using simple conv net.')
    model_selection.add_argument('-u', '--unet', action='store_true',
                                 help='Export using Unet net.')
    model_selection.add_argument('-g', '--gan', action='store_true',
                                 help='Export using GAN net.')

    parser.add_argument('-n', '--noise', action='store_true',
                        help='Add noise to HR before augmentation.')
    parser.add_argument('-m', '--match_hist', action='store_true',
                        help='Match HR hist with real LR before augmentation.')
    parser.add_argument('-d', '--demo', action='store_true',
                        help='Don\'t export dataset, demo inference.')
    parser.add_argument('weights_path')

    args = parser.parse_args()

    if args.simple:
        model_type = Models.SIMPLE_CONV
    elif args.unet:
        model_type = Models.UNET
    elif args.gan:
        model_type = Models.GAN

    params = make_params(Path('params.yaml'), model_type)
    weights_path = Path(args.weights_path)
    add_noise = args.noise
    match_hist = args.match_hist

    if args.weights_path != '':
        model = make_model(
            model_type,
            params['load']['input_shape'],
            use_lr_masks=False)
        model.load_weights(args.weights_path)
    else:
        model = model_transform_to_lr_bicubic

    if args.demo:
        demo_hr_path = Path(
            'data/'
            'proba-v_registered_b/'
            'train/'
            'NIR/'
            'imgset0648/'
            'HR000.png')
        demo_export(model, demo_hr_path, add_noise)
    else:
        unregisterd_proba_path = Path('data/proba-v')
        registerd_proba_path = Path('data/proba-v_registered_b')
        if args.weights_path != '':
            suffix = str(weights_path.stem)
        else:
            suffix = 'bicubic'
        transform_proba_dataset_3xlrs(
            model, unregisterd_proba_path, registerd_proba_path, suffix, add_noise, match_hist)
Beispiel #5
0
def main():
    enable_gpu_if_possible()

    parser = argparse.ArgumentParser(description='Export Sentinel-2 dataset.')

    model_selection = parser.add_mutually_exclusive_group()
    model_selection.add_argument('-s',
                                 '--simple',
                                 action='store_true',
                                 help='Export using simple conv net.')
    model_selection.add_argument('-u',
                                 '--unet',
                                 action='store_true',
                                 help='Export using Unet net.')
    model_selection.add_argument('-g',
                                 '--gan',
                                 action='store_true',
                                 help='Export using GAN net.')

    parser.add_argument('-r',
                        '--random_translations',
                        action='store_true',
                        help='Generate random LR translations instead of using'
                        ' transaltions file.')
    parser.add_argument('-d',
                        '--demo',
                        action='store_true',
                        help='Don\'t export dataset, demo inference.')
    parser.add_argument('weights_path')

    args = parser.parse_args()

    if args.simple:
        model_type = Models.SIMPLE_CONV
    elif args.unet:
        model_type = Models.UNET
    elif args.gan:
        model_type = Models.GAN

    params = make_params(Path('params.yaml'), model_type)
    weights_path = Path(args.weights_path)

    model = make_model(model_type,
                       params['load']['input_shape'],
                       use_lr_masks=False)
    model.load_weights(args.weights_path)

    if args.demo:
        demo_hr_path = Path(
            'data/'
            'sentinel-2_artificial/'
            'S2B_MSIL1C_20200806T105619_N0209_R094_T30TWP_20200806T121751/'
            '08280x10440/'
            'b8/'
            'hr.png')
        demo_export(model, demo_hr_path)
    else:
        sentinel_root_path = Path('data/sentinel-2_artificial/')
        suffix = str(weights_path.stem)
        transform_sentinel_dataset_3xlrs(model, sentinel_root_path, suffix,
                                         args.random_translations)