Ejemplo n.º 1
0
def parse_args():
    """Parse command line arguments."""

    # Testing settings
    TEST_DATA = DATASET_NAMES[3]  # max 8
    data_inf = dataset_info(TEST_DATA)

    parser = argparse.ArgumentParser(description='DexiNed trainer.')
    # Data parameters
    parser.add_argument('--input_dir',
                        type=str,
                        default='/opt/dataset/BIPED/edges',
                        help='the path to the directory with the input data.')
    parser.add_argument(
        '--input_val_dir',
        type=str,
        default=data_inf['data_dir'],
        help='the path to the directory with the input data for validation.')
    parser.add_argument('--output_dir',
                        type=str,
                        default='checkpoints',
                        help='the path to output the results.')
    parser.add_argument('--test_data',
                        type=str,
                        choices=DATASET_NAMES,
                        default=TEST_DATA,
                        help='Name of the dataset.')
    parser.add_argument('--test_list',
                        type=str,
                        default=data_inf['file_name'],
                        help='Dataset sample indices list.')
    parser.add_argument('--is_testing',
                        type=bool,
                        default=False,
                        help='Put script in testing mode.')
    # parser.add_argument('--use_prev_trained',
    #                     type=bool,
    #                     default=True,
    #                     help='use previous trained data')  # Just for test
    parser.add_argument(
        '--checkpoint_data',
        type=str,
        default='24/24_model.pth',
        help='Checkpoint path from which to restore model weights from.')
    parser.add_argument('--test_img_width',
                        type=int,
                        default=data_inf['img_width'],
                        help='Image width for testing.')
    parser.add_argument('--test_img_height',
                        type=int,
                        default=data_inf['img_height'],
                        help='Image height for testing.')
    parser.add_argument('--res_dir',
                        type=str,
                        default='result',
                        help='Result directory')
    parser.add_argument(
        '--log_interval_vis',
        type=int,
        default=50,
        help='The number of batches to wait before printing test predictions.')

    # Optimization parameters
    # parser.add_argument('--optimizer',
    #                     type=str,
    #                     choices=['adam', 'sgd'],
    #                     default='adam',
    #                     help='The optimizer to use (default: adam).')
    parser.add_argument('--epochs',
                        type=int,
                        default=25,
                        metavar='N',
                        help='Number of training epochs (default: 25).')
    parser.add_argument('--lr',
                        default=1e-4,
                        type=float,
                        help='Initial learning rate.')
    parser.add_argument('--wd',
                        type=float,
                        default=1e-4,
                        metavar='WD',
                        help='weight decay (default: 1e-4)')
    # parser.add_argument('--lr_stepsize',
    #                     default=1e4,
    #                     type=int,
    #                     help='Learning rate step size.')
    parser.add_argument('--batch_size',
                        type=int,
                        default=8,
                        metavar='B',
                        help='the mini-batch size (default: 8)')
    parser.add_argument('--workers',
                        default=8,
                        type=int,
                        help='The number of workers for the dataloaders.')
    parser.add_argument('--tensorboard',
                        type=bool,
                        default=True,
                        help='Use Tensorboard for logging.'),
    parser.add_argument('--img_width',
                        type=int,
                        default=400,
                        help='Image width for training.')
    parser.add_argument('--img_height',
                        type=int,
                        default=400,
                        help='Image height for training.')
    parser.add_argument('--channel_swap', default=[2, 1, 0], type=int)
    parser.add_argument(
        '--crop_img',
        default=False,
        type=bool,
        help=
        'If true crop training images, else resize images to match image width and height.'
    )
    parser.add_argument(
        '--mean_pixel_values',
        default=[103.939, 116.779, 123.68, 137.86],
        type=float
    )  # [103.939,116.779,123.68] [104.00699, 116.66877, 122.67892]
    args = parser.parse_args()
    return args
Ejemplo n.º 2
0
def parse_args():
    """Parse command line arguments."""
    parser = argparse.ArgumentParser(description='DexiNed trainer.')
    parser.add_argument(
        '--choose_test_data',
        type=int,
        default=-1,
        help='Already set the dataset for testing choice: 0 - 8')
    # ----------- test -------0--

    TEST_DATA = DATASET_NAMES[parser.parse_args().choose_test_data]  # max 8
    data_inf = dataset_info(TEST_DATA, is_linux=IS_LINUX)
    test_dir = data_inf['data_dir']
    is_testing = True  # current test _bdcnlossNew256-sd7-1.10.4p5

    # Training settings
    TRAIN_DATA = DATASET_NAMES[0]  # BIPED=0
    train_info = dataset_info(TRAIN_DATA, is_linux=IS_LINUX)
    train_dir = train_info['data_dir']

    # Data parameters
    parser.add_argument('--input_dir',
                        type=str,
                        default=train_dir,
                        help='the path to the directory with the input data.')
    parser.add_argument(
        '--input_val_dir',
        type=str,
        default=data_inf['data_dir'],
        help='the path to the directory with the input data for validation.')
    parser.add_argument('--output_dir',
                        type=str,
                        default='checkpoints',
                        help='the path to output the results.')
    parser.add_argument('--train_data',
                        type=str,
                        choices=DATASET_NAMES,
                        default=TRAIN_DATA,
                        help='Name of the dataset.')
    parser.add_argument('--test_data',
                        type=str,
                        choices=DATASET_NAMES,
                        default=TEST_DATA,
                        help='Name of the dataset.')
    parser.add_argument('--test_list',
                        type=str,
                        default=data_inf['test_list'],
                        help='Dataset sample indices list.')
    parser.add_argument('--is_testing',
                        type=bool,
                        default=is_testing,
                        help='Script in testing mode.')
    parser.add_argument(
        '--double_img',
        type=bool,
        default=False,
        help='True: use same 2 imgs changing channels')  # Just for test
    parser.add_argument('--resume',
                        type=bool,
                        default=False,
                        help='use previous trained data')  # Just for test
    parser.add_argument(
        '--checkpoint_data',
        type=str,
        default='19/19_model.pth',
        help='Checkpoint path from which to restore model weights from.')
    parser.add_argument('--test_img_width',
                        type=int,
                        default=data_inf['img_width'],
                        help='Image width for testing.')
    parser.add_argument('--test_img_height',
                        type=int,
                        default=data_inf['img_height'],
                        help='Image height for testing.')
    parser.add_argument('--res_dir',
                        type=str,
                        default='result',
                        help='Result directory')
    parser.add_argument(
        '--log_interval_vis',
        type=int,
        default=50,
        help='The number of batches to wait before printing test predictions.')

    parser.add_argument('--epochs',
                        type=int,
                        default=25,
                        metavar='N',
                        help='Number of training epochs (default: 25).')
    parser.add_argument('--lr',
                        default=1e-4,
                        type=float,
                        help='Initial learning rate.')
    parser.add_argument('--wd',
                        type=float,
                        default=1e-4,
                        metavar='WD',
                        help='weight decay (default: 1e-4)')
    # parser.add_argument('--lr_stepsize',
    #                     default=1e4,
    #                     type=int,
    #                     help='Learning rate step size.')
    parser.add_argument('--batch_size',
                        type=int,
                        default=8,
                        metavar='B',
                        help='the mini-batch size (default: 8)')
    parser.add_argument('--workers',
                        default=8,
                        type=int,
                        help='The number of workers for the dataloaders.')
    parser.add_argument('--tensorboard',
                        type=bool,
                        default=True,
                        help='Use Tensorboard for logging.'),
    parser.add_argument('--img_width',
                        type=int,
                        default=400,
                        help='Image width for training.')
    parser.add_argument('--img_height',
                        type=int,
                        default=400,
                        help='Image height for training.')
    parser.add_argument('--channel_swap', default=[2, 1, 0], type=int)
    parser.add_argument(
        '--crop_img',
        default=True,
        type=bool,
        help=
        'If true crop training images, else resize images to match image width and height.'
    )
    parser.add_argument(
        '--mean_pixel_values',
        default=[103.939, 116.779, 123.68, 137.86],
        type=float
    )  # [103.939,116.779,123.68] [104.00699, 116.66877, 122.67892]
    args = parser.parse_args()
    return args