Exemplo n.º 1
0
def parse_config():
    parser = argparse.ArgumentParser(description='arg parser')
    parser.add_argument('--cfg_file', type=str, default=None, help='specify the config for training')

    parser.add_argument('--batch_size', type=int, default=None, required=False, help='batch size for training')
    parser.add_argument('--workers', type=int, default=4, help='number of workers for dataloader')
    parser.add_argument('--extra_tag', type=str, default='default', help='extra tag for this experiment')
    parser.add_argument('--ckpt', type=str, default=None, help='checkpoint to start from')
    parser.add_argument('--launcher', choices=['none', 'pytorch', 'slurm'], default='none')
    parser.add_argument('--tcp_port', type=int, default=18888, help='tcp port for distrbuted training')
    parser.add_argument('--local_rank', type=int, default=50, help='local rank for distributed training')
    parser.add_argument('--set', dest='set_cfgs', default=None, nargs=argparse.REMAINDER,
                        help='set extra config keys if needed')

    parser.add_argument('--max_waiting_mins', type=int, default=30, help='max waiting minutes')
    parser.add_argument('--start_epoch', type=int, default=0, help='')
    parser.add_argument('--eval_tag', type=str, default='default', help='eval tag for this experiment')
    parser.add_argument('--eval_all', action='store_true', default=False, help='whether to evaluate all checkpoints')
    parser.add_argument('--ckpt_dir', type=str, default=None, help='specify a ckpt directory to be evaluated if needed')
    parser.add_argument('--save_to_file', action='store_true', default=False, help='')

    args = parser.parse_args()

    cfg_from_yaml_file(args.cfg_file, cfg)
    cfg.TAG = Path(args.cfg_file).stem
    cfg.EXP_GROUP_PATH = '/'.join(args.cfg_file.split('/')[1:-1])  # remove 'cfgs' and 'xxxx.yaml'

    np.random.seed(1024)

    if args.set_cfgs is not None:
        cfg_from_list(args.set_cfgs, cfg)

    return args, cfg
Exemplo n.º 2
0
def parse_config():
    parser = argparse.ArgumentParser(description='arg parser')
    parser.add_argument('--cfg_file', type=str, default='/home/syang/Data/data_object_velodyne/output/kitti_models/centernet_multihead/0124_single_head/centernet_multihead.yaml', help='specify the config for training')

    parser.add_argument('--batch_size', type=int, default=1, required=False, help='batch size for training')
    parser.add_argument('--workers', type=int, default=16, help='number of workers for dataloader')
    parser.add_argument('--extra_tag', type=str, default='0129_twostage_first_4', help='extra tag for this experiment')
    # os.path.abspath('..') + '/output/robosense_models/robosense_pointpillar/BResampl_LR001/ckpt/checkpoint_epoch_30.pth'
    parser.add_argument('--ckpt', type=str, default='/home/syang/Data/data_object_velodyne/output/kitti_models/centernet_multihead/0124_single_head/ckpt/checkpoint_epoch_80.pth', help='checkpoint to start from')
    parser.add_argument('--launcher', choices=['none', 'pytorch', 'slurm'], default='none')
    parser.add_argument('--tcp_port', type=int, default=18888, help='tcp port for distrbuted training')
    parser.add_argument('--local_rank', type=int, default=0, help='local rank for distributed training')
    parser.add_argument('--set', dest='set_cfgs', default=None, nargs=argparse.REMAINDER,
                        help='set extra config keys if needed')

    parser.add_argument('--max_waiting_mins', type=int, default=30, help='max waiting minutes')
    parser.add_argument('--start_epoch', type=int, default=0, help='')
    parser.add_argument('--eval_tag', type=str, default='default', help='eval tag for this experiment')
    parser.add_argument('--eval_all', action='store_true', default=False, help='whether to evaluate all checkpoints')
    parser.add_argument('--ckpt_dir', type=str, default=None, help='specify a ckpt directory to be evaluated if needed')
    parser.add_argument('--save_to_file', action='store_true', default=False, help='')

    args = parser.parse_args()

    cfg_from_yaml_file(args.cfg_file, cfg)
    cfg.TAG = Path(args.cfg_file).stem
    cfg.EXP_GROUP_PATH = '/'.join(args.cfg_file.split('/')[1:-1])  # remove 'cfgs' and 'xxxx.yaml'

    np.random.seed(1024)

    if args.set_cfgs is not None:
        cfg_from_list(args.set_cfgs, cfg)

    return args, cfg
Exemplo n.º 3
0
def parse_config():
    parser = argparse.ArgumentParser(description='arg parser')
    parser.add_argument('--cfg_file', type=str, default=None, help='specify the config for training')

    parser.add_argument('--batch_size', type=int, default=None, required=False, help='batch size for training')
    parser.add_argument('--epochs', type=int, default=None, required=False, help='number of epochs to train for')
    parser.add_argument('--workers', type=int, default=8, help='number of workers for dataloader')
    parser.add_argument('--extra_tag', type=str, default='default', help='extra tag for this experiment')
    parser.add_argument('--ckpt', type=str, default=None, help='checkpoint to start from')
    parser.add_argument('--pretrained_model', type=str, default=None, help='pretrained_model')
    parser.add_argument('--launcher', choices=['none', 'pytorch', 'slurm'], default='none')
    parser.add_argument('--tcp_port', type=int, default=18888, help='tcp port for distrbuted training')
    parser.add_argument('--sync_bn', action='store_true', default=False, help='whether to use sync bn')
    parser.add_argument('--fix_random_seed', action='store_true', default=False, help='')
    parser.add_argument('--ckpt_save_interval', type=int, default=1, help='number of training epochs')
    parser.add_argument('--local_rank', type=int, default=0, help='local rank for distributed training')
    parser.add_argument('--max_ckpt_save_num', type=int, default=30, help='max number of saved checkpoint')
    parser.add_argument('--merge_all_iters_to_one_epoch', action='store_true', default=False, help='')
    parser.add_argument('--set', dest='set_cfgs', default=None, nargs=argparse.REMAINDER,
                        help='set extra config keys if needed')

    parser.add_argument('--max_waiting_mins', type=int, default=0, help='max waiting minutes')
    parser.add_argument('--start_epoch', type=int, default=0, help='')
    parser.add_argument('--save_to_file', action='store_true', default=False, help='')

    args = parser.parse_args()

    cfg_from_yaml_file(args.cfg_file, cfg)
    cfg.TAG = Path(args.cfg_file).stem
    cfg.EXP_GROUP_PATH = '/'.join(args.cfg_file.split('/')[1:-1])  # remove 'cfgs' and 'xxxx.yaml'

    if args.set_cfgs is not None:
        cfg_from_list(args.set_cfgs, cfg)

    return args, cfg
Exemplo n.º 4
0
def parse_config():
    parser = argparse.ArgumentParser(description='arg parser')
    parser.add_argument('--cfg_file',
                        type=str,
                        default=None,
                        help='specify the config for training')

    parser.add_argument('--data_dir', type=str, default=None)
    parser.add_argument('--batch_size',
                        type=int,
                        default=16,
                        required=False,
                        help='batch size for training')
    parser.add_argument('--epochs',
                        type=int,
                        default=80,
                        required=False,
                        help='number of epochs to train for')
    parser.add_argument('--workers',
                        type=int,
                        default=4,
                        help='number of workers for dataloader')
    parser.add_argument('--extra_tag',
                        type=str,
                        default='default',
                        help='extra tag for this experiment')
    parser.add_argument('--ckpt',
                        type=str,
                        default=None,
                        help='checkpoint to start from')
    parser.add_argument('--pretrained_model',
                        type=str,
                        default=None,
                        help='pretrained_model')
    parser.add_argument('--launcher',
                        choices=['none', 'pytorch', 'slurm'],
                        default='none')
    parser.add_argument('--federated',
                        choices=['none', 'sync', 'async'],
                        default='none')  #NOTE: for federated learning
    parser.add_argument('--tcp_port',
                        type=int,
                        default=18888,
                        help='tcp port for distributed training')
    parser.add_argument('--sync_bn',
                        action='store_true',
                        default=False,
                        help='whether to use sync bn')
    parser.add_argument('--fix_random_seed',
                        action='store_true',
                        default=False,
                        help='whether to use sync bn')
    parser.add_argument('--ckpt_save_interval',
                        type=int,
                        default=2,
                        help='number of training epochs')
    parser.add_argument('--local_rank',
                        type=int,
                        default=0,
                        help='local rank for distributed training')
    parser.add_argument('--max_ckpt_save_num',
                        type=int,
                        default=30,
                        help='max number of saved checkpoint')
    parser.add_argument('--set',
                        dest='set_cfgs',
                        default=None,
                        nargs=argparse.REMAINDER,
                        help='set extra config keys if needed')

    args = parser.parse_args()

    cfg_from_yaml_file(args.cfg_file, cfg)
    cfg.TAG = Path(args.cfg_file).stem
    if args.set_cfgs is not None:
        cfg_from_list(args.set_cfgs, cfg)

    return args, cfg
Exemplo n.º 5
0
def parse_config():
    parser = argparse.ArgumentParser(description='arg parser')
    parser.add_argument('--cfg_file',
                        type=str,
                        default=None,
                        help='specify the config for training')

    parser.add_argument('--batch_size',
                        type=int,
                        default=None,
                        required=False,
                        help='batch size for training')
    parser.add_argument('--epochs',
                        type=int,
                        default=None,
                        required=False,
                        help='number of epochs to train for')
    parser.add_argument('--workers',
                        type=int,
                        default=8,
                        help='number of workers for dataloader')
    parser.add_argument('--extra_tag',
                        type=str,
                        default='default',
                        help='extra tag for this experiment')
    parser.add_argument('--ckpt',
                        type=str,
                        default=None,
                        help='checkpoint to start from')
    parser.add_argument('--pretrained_model',
                        type=str,
                        default=None,
                        help='pretrained_model')
    parser.add_argument('--launcher',
                        choices=['none', 'pytorch', 'slurm'],
                        default='none')
    parser.add_argument('--tcp_port',
                        type=int,
                        default=18888,
                        help='tcp port for distrbuted training')
    parser.add_argument('--sync_bn',
                        action='store_true',
                        default=False,
                        help='whether to use sync bn')
    parser.add_argument('--fix_random_seed',
                        action='store_true',
                        default=False,
                        help='')
    parser.add_argument('--ckpt_save_interval',
                        type=int,
                        default=1,
                        help='number of training epochs')
    parser.add_argument('--local_rank',
                        type=int,
                        default=0,
                        help='local rank for distributed training')
    parser.add_argument('--max_ckpt_save_num',
                        type=int,
                        default=30,
                        help='max number of saved checkpoint')
    parser.add_argument('--merge_all_iters_to_one_epoch',
                        action='store_true',
                        default=False,
                        help='')
    parser.add_argument('--set',
                        dest='set_cfgs',
                        default=None,
                        nargs=argparse.REMAINDER,
                        help='set extra config keys if needed')

    parser.add_argument('--max_waiting_mins',
                        type=int,
                        default=0,
                        help='max waiting minutes')
    parser.add_argument('--start_epoch', type=int, default=0, help='')
    parser.add_argument('--save_to_file',
                        action='store_true',
                        default=False,
                        help='')
    parser.add_argument('--adv',
                        action='store_true',
                        default=False,
                        help='adv defense or not')
    parser.add_argument('--norm', type=str, default='inf', help='norm type')
    parser.add_argument('--epsilon',
                        type=float,
                        default=0.01,
                        help='epsilon value')
    parser.add_argument('--rec_type',
                        type=str,
                        default='both',
                        help='both: attack to points and reflectance'
                        'points: attack to points only'
                        'reflectance: attack to reflectance only')
    parser.add_argument('--iterations',
                        type=int,
                        default=1,
                        help='iterations of different method')
    parser.add_argument(
        '--pgd',
        type=bool,
        default=False,
        help=
        'pgd adversarial type, when pgd is True, momentum should be False and iterations should be 10'
    )
    parser.add_argument(
        '--momentum',
        type=bool,
        default=False,
        help=
        'adversarial type momentum, when momentum is True, pgd should be False and iterations should be 10'
    )
    parser.add_argument('--cfg_root_dir',
                        type=str,
                        default='',
                        help='model and relative informations save dir')
    args = parser.parse_args()

    cfg_from_yaml_file(args.cfg_file, cfg)
    cfg.TAG = Path(args.cfg_file).stem
    cfg.EXP_GROUP_PATH = '/'.join(
        args.cfg_file.split('/')[1:-1])  # remove 'cfgs' and 'xxxx.yaml'

    if args.set_cfgs is not None:
        cfg_from_list(args.set_cfgs, cfg)

    return args, cfg