def parse_demo_configs(): parser = argparse.ArgumentParser(description='Demonstration config for the implementation') parser.add_argument('--saved_fn', type=str, default='fpn_resnet_18', metavar='FN', help='The name using for saving logs, models,...') parser.add_argument('-a', '--arch', type=str, default='fpn_resnet_18', metavar='ARCH', help='The name of the model architecture') parser.add_argument('--pretrained_path', type=str, default='../checkpoints/fpn_resnet_18/fpn_resnet_18_epoch_300.pth', metavar='PATH', help='the path of the pretrained checkpoint') parser.add_argument('--foldername', type=str, default='2011_09_26_drive_0014_sync', metavar='FN', help='Folder name for demostration dataset') parser.add_argument('--K', type=int, default=50, help='the number of top K') parser.add_argument('--no_cuda', action='store_true', help='If true, cuda is not used.') parser.add_argument('--gpu_idx', default=0, type=int, help='GPU index to use.') parser.add_argument('--peak_thresh', type=float, default=0.2) parser.add_argument('--output_format', type=str, default='image', metavar='PATH', help='the type of the test output (support image or video)') parser.add_argument('--output-width', type=int, default=608, help='the width of showing output, the height maybe vary') configs = edict(vars(parser.parse_args())) configs.pin_memory = True configs.distributed = False # For testing on 1 GPU only configs.input_size = (608, 608) configs.hm_size = (152, 152) configs.down_ratio = 4 configs.max_objects = 50 configs.imagenet_pretrained = False configs.head_conv = 64 configs.num_classes = 3 configs.num_center_offset = 2 configs.num_z = 1 configs.num_dim = 3 configs.num_direction = 2 # sin, cos configs.heads = { 'hm_cen': configs.num_classes, 'cen_offset': configs.num_center_offset, 'direction': configs.num_direction, 'z_coor': configs.num_z, 'dim': configs.num_dim } #################################################################### ##############Dataset, Checkpoints, and results dir configs######### #################################################################### configs.root_dir = '../' configs.dataset_dir = os.path.join(configs.root_dir, 'dataset', 'kitti', 'demo') configs.calib_path = os.path.join(configs.root_dir, 'dataset', 'kitti', 'demo', 'calib.txt') configs.results_dir = os.path.join(configs.root_dir, 'results', configs.saved_fn) make_folder(configs.results_dir) return configs
def parse_test_configs(): parser = argparse.ArgumentParser(description='Testing config for the Implementation') parser.add_argument('--saved_fn', type=str, default='fpn_resnet_18', metavar='FN', help='The name using for saving logs, models,...') parser.add_argument('-a', '--arch', type=str, default='fpn_resnet_18', metavar='ARCH', help='The name of the model architecture') parser.add_argument('--pretrained_path', type=str, default='../checkpoints/fpn_resnet_18/Model_fpn_resnet_18_epoch_30.pth', metavar='PATH') parser.add_argument('--K', type=int, default=50, help='the number of top K') parser.add_argument('--no_cuda', action='store_true', help='If true, cuda is not used.') parser.add_argument('--gpu_idx', default=0, type=int, help='GPU index to use.') parser.add_argument('--num_samples', type=int, default=None, help='Take a subset of the dataset to run and debug') parser.add_argument('--num_workers', type=int, default=1, help='Number of threads for loading data') parser.add_argument('--batch_size', type=int, default=1, help='mini-batch size (default: 4)') parser.add_argument('--peak_thresh', type=float, default=0.2) parser.add_argument('--save_test_output', action='store_true', help='If true, the output image of the testing phase will be saved') parser.add_argument('--output_format', type=str, default='image', metavar='PATH', help='the type of the test output (support image or video)') parser.add_argument('--output_video_fn', type=str, default='out_fpn_resnet_18',metavar='PATH',help='video path if the output format is video') parser.add_argument('--output-width', type=int, default=608, help='the width of showing output, the height maybe vary') parser.add_argument('--SDN', action='store_true', help="Psuedo LIDAR from SDN Depth Estimation") configs = edict(vars(parser.parse_args())) configs.pin_memory = True configs.distributed = False # For testing on 1 GPU only configs.input_size = (608, 608) configs.hm_size = (152, 152) configs.down_ratio = 4 configs.max_objects = 50 configs.imagenet_pretrained = False configs.head_conv = 64 configs.num_classes = 3 configs.num_center_offset = 2 configs.num_z = 1 configs.num_dim = 3 configs.num_direction = 2 # sin, cos configs.heads = { 'hm_cen': configs.num_classes, 'cen_offset': configs.num_center_offset, 'direction': configs.num_direction, 'z_coor': configs.num_z, 'dim': configs.num_dim } configs.num_input_features = 4 #################################################################### ##############Dataset, Checkpoints, and results dir configs######### #################################################################### configs.root_dir = '../' configs.dataset_dir = os.path.join(configs.root_dir, '../' , 'data', 'kitti') if configs.save_test_output: configs.results_dir = os.path.join(configs.root_dir, 'results', configs.saved_fn) make_folder(configs.results_dir) args = parser.parse_args() return configs, args
def parse_test_configs(): parser = argparse.ArgumentParser(description='Demonstration config for Complex YOLO Implementation') parser.add_argument('--saved_fn', type=str, default='complexer_yolov4', metavar='FN', help='The name using for saving logs, models,...') parser.add_argument('-a', '--arch', type=str, default='darknet', metavar='ARCH', help='The name of the model architecture') parser.add_argument('--cfgfile', type=str, default='./config/cfg/complex_yolov4.cfg', metavar='PATH', help='The path for cfgfile (only for darknet)') parser.add_argument('--pretrained_path', type=str, default=None, metavar='PATH', help='the path of the pretrained checkpoint') parser.add_argument('--use_giou_loss', action='store_true', help='If true, use GIoU loss during training. If false, use MSE loss for training') parser.add_argument('--no_cuda', action='store_true', help='If true, cuda is not used.') parser.add_argument('--gpu_idx', default=0, type=int, help='GPU index to use.') parser.add_argument('--img_size', type=int, default=608, help='the size of input image') parser.add_argument('--num_samples', type=int, default=None, help='Take a subset of the dataset to run and debug') parser.add_argument('--num_workers', type=int, default=1, help='Number of threads for loading data') parser.add_argument('--batch_size', type=int, default=1, help='mini-batch size (default: 4)') parser.add_argument('--conf_thresh', type=float, default=0.5, help='the threshold for conf') parser.add_argument('--nms_thresh', type=float, default=0.1, help='the threshold for conf') parser.add_argument('--show_image', action='store_true', help='If true, show the image during demostration') parser.add_argument('--save_test_output', action='store_true', help='If true, the output image of the testing phase will be saved') parser.add_argument('--output_format', type=str, default='image', metavar='PATH', help='the type of the test output (support image or video)') parser.add_argument('--output_video_fn', type=str, default='out_complexer_yolov4', metavar='PATH', help='the video filename if the output format is video') configs = edict(vars(parser.parse_args())) configs.pin_memory = True #################################################################### ##############Dataset, Checkpoints, and results dir configs######### #################################################################### configs.working_dir = '../' configs.dataset_dir = '/media/wx/File/labeldata/mydata' if configs.save_test_output: configs.results_dir = os.path.join(configs.working_dir, 'results', configs.saved_fn) make_folder(configs.results_dir) return configs
def parse_test_configs(): parser = argparse.ArgumentParser(description='Demonstration config for Complex YOLO Implementation') parser.add_argument('--saved_fn', type=str, default='complexer_yolo', metavar='FN', help='The name using for saving logs, models,...') parser.add_argument('-a', '--arch', type=str, default='darknet', metavar='ARCH', help='The name of the model architecture') parser.add_argument('--cfgfile', type=str, default='./config/complex_yolov4.cfg', metavar='PATH', help='The path for cfgfile (only for darknet)') parser.add_argument('--pretrained_path', type=str, default=None, metavar='PATH', help='the path of the pretrained checkpoint') parser.add_argument('--no_cuda', action='store_true', help='If true, cuda is not used.') parser.add_argument('--gpu_idx', default=None, type=int, help='GPU index to use.') parser.add_argument('--img_size', type=int, default=608, help='the size of input image') parser.add_argument('--num_samples', type=int, default=None, help='Take a subset of the dataset to run and debug') parser.add_argument('--num_workers', type=int, default=4, help='Number of threads for loading data') parser.add_argument('--batch_size', type=int, default=4, help='mini-batch size (default: 4)') parser.add_argument('--video_path', type=str, default=None, metavar='PATH', help='the path of the video that needs to demo') parser.add_argument('--output_format', type=str, default='text', metavar='PATH', help='the type of the demo output') parser.add_argument('--show_image', action='store_true', help='If true, show the image during demostration') parser.add_argument('--save_demo_output', action='store_true', help='If true, the image of demonstration phase will be saved') configs = edict(vars(parser.parse_args())) configs.pin_memory = True #################################################################### ##############Dataset, Checkpoints, and results dir configs######### #################################################################### configs.working_dir = '../' configs.dataset_dir = os.path.join(configs.working_dir, 'dataset', 'kitti') configs.checkpoints_dir = os.path.join(configs.working_dir, 'checkpoints', configs.saved_fn) configs.results_dir = os.path.join(configs.working_dir, 'results', configs.saved_fn) make_folder(configs.results_dir) return configs
def parse_configs(): parser = argparse.ArgumentParser(description='TTNet Implementation') parser.add_argument('--seed', type=int, default=2020, help='re-produce the results with seed random') parser.add_argument('--saved_fn', type=str, default='ttnet', metavar='FN', help='The name using for saving logs, models,...') #################################################################### ############## Model configs ################### #################################################################### parser.add_argument('-a', '--arch', type=str, default='ttnet', metavar='ARCH', help='The name of the model architecture') parser.add_argument('--dropout_p', type=float, default=0.5, metavar='P', help='The dropout probability of the model') parser.add_argument( '--multitask_learning', action='store_true', help='If true, the weights of different losses will be learnt (train).' 'If false, a regular sum of different losses will be applied') parser.add_argument('--no_local', action='store_true', help='If true, no local stage for ball detection.') parser.add_argument('--no_event', action='store_true', help='If true, no event spotting detection.') parser.add_argument('--no_seg', action='store_true', help='If true, no segmentation module.') parser.add_argument('--pretrained_path', type=str, default=None, metavar='PATH', help='the path of the pretrained checkpoint') parser.add_argument( '--overwrite_global_2_local', action='store_true', help= 'If true, the weights of the local stage will be overwritten by the global stage.' ) #################################################################### ############## Dataloader and Running configs ####### #################################################################### parser.add_argument( '--no-val', action='store_true', help='If true, use all data for training, no validation set') parser.add_argument('--val-size', type=float, default=0.2, help='The size of validation set') parser.add_argument('--num_samples', type=int, default=None, help='Take a subset of the dataset to run and debug') parser.add_argument('--num_workers', type=int, default=8, help='Number of threads for loading data') parser.add_argument('--batch_size', type=int, default=32, help='mini-batch size (default: 16), this is the total' 'batch size of all GPUs on the current node when using' 'Data Parallel or Distributed Data Parallel') parser.add_argument('--print_freq', type=int, default=10, metavar='N', help='print frequency (default: 10)') parser.add_argument('--checkpoint_freq', type=int, default=3, metavar='N', help='frequency of saving checkpoints (default: 3)') parser.add_argument( '--sigma', type=float, default=0.5, metavar='SIGMA', help= 'standard deviation of the 1D Gaussian for the ball position target') parser.add_argument( '--thresh_ball_pos_mask', type=float, default=0.01, metavar='THRESH', help='the lower thresh for the 1D Gaussian of the ball position target' ) #################################################################### ############## Training strategy ################### #################################################################### parser.add_argument('--start_epoch', type=int, default=1, metavar='N', help='the starting epoch') parser.add_argument('--num_epochs', type=int, default=40, metavar='N', help='number of total epochs to run') parser.add_argument('--lr', type=float, default=1e-3, metavar='LR', help='initial learning rate') parser.add_argument('--minimum_lr', type=float, default=1e-7, metavar='MIN_LR', help='minimum learning rate during training') parser.add_argument('--momentum', type=float, default=0.9, metavar='M', help='momentum') parser.add_argument('-wd', '--weight_decay', type=float, default=1e-6, metavar='WD', help='weight decay (default: 1e-6)') parser.add_argument('--optimizer_type', type=str, default='adam', metavar='OPTIMIZER', help='the type of optimizer, it can be sgd or adam') parser.add_argument( '--lr_type', type=str, default='plateau', metavar='SCHEDULER', help= 'the type of the learning rate scheduler (steplr or ReduceonPlateau)') parser.add_argument('--lr_factor', type=float, default=0.5, metavar='FACTOR', help='reduce the learning rate with this factor') parser.add_argument( '--lr_step_size', type=int, default=5, metavar='STEP_SIZE', help='step_size of the learning rate when using steplr scheduler') parser.add_argument( '--lr_patience', type=int, default=3, metavar='N', help='patience of the learning rate when using ReduceoPlateau scheduler' ) parser.add_argument( '--earlystop_patience', type=int, default=12, metavar='N', help= 'Early stopping the training process if performance is not improved within this value' ) parser.add_argument( '--freeze_global', action='store_true', help= 'If true, no update/train weights for the global stage of ball detection.' ) parser.add_argument( '--freeze_local', action='store_true', help= 'If true, no update/train weights for the local stage of ball detection.' ) parser.add_argument( '--freeze_event', action='store_true', help='If true, no update/train weights for the event module.') parser.add_argument( '--freeze_seg', action='store_true', help='If true, no update/train weights for the segmentation module.') #################################################################### ############## Loss weight ################### #################################################################### parser.add_argument( '--bce_weight', type=float, default=0.5, help= 'The weight of BCE loss in segmentation module, the dice_loss weight = 1- bce_weight' ) parser.add_argument( '--global_weight', type=float, default=1., help='The weight of loss of the global stage for ball detection') parser.add_argument( '--local_weight', type=float, default=1., help='The weight of loss of the local stage for ball detection') parser.add_argument('--event_weight', type=float, default=1., help='The weight of loss of the event spotting module') parser.add_argument('--seg_weight', type=float, default=1., help='The weight of BCE loss in segmentation module') #################################################################### ############## Distributed Data Parallel ############ #################################################################### parser.add_argument('--world-size', default=-1, type=int, metavar='N', help='number of nodes for distributed training') parser.add_argument('--rank', default=-1, type=int, metavar='N', help='node rank for distributed training') parser.add_argument('--dist-url', default='tcp://127.0.0.1:29500', type=str, help='url used to set up distributed training') parser.add_argument('--dist-backend', default='nccl', type=str, help='distributed backend') parser.add_argument('--gpu_idx', default=None, type=int, help='GPU index to use.') parser.add_argument('--no_cuda', action='store_true', help='If true, cuda is not used.') parser.add_argument( '--multiprocessing-distributed', action='store_true', help='Use multi-processing distributed training to launch ' 'N processes per node, which has N GPUs. This is the ' 'fastest way to use PyTorch for either single node or ' 'multi node data parallel training') #################################################################### ############## Evaluation configurations ################### #################################################################### parser.add_argument('--evaluate', action='store_true', help='only evaluate the model, not training') parser.add_argument('--resume_path', type=str, default=None, metavar='PATH', help='the path of the resumed checkpoint') parser.add_argument( '--use_best_checkpoint', action='store_true', help= 'If true, choose the best model on val set, otherwise choose the last model' ) parser.add_argument('--seg_thresh', type=float, default=0.5, help='threshold of the segmentation output') parser.add_argument('--event_thresh', type=float, default=0.5, help='threshold of the event spotting output') parser.add_argument( '--save_test_output', action='store_true', help='If true, the image of testing phase will be saved') configs = edict(vars(parser.parse_args())) #################################################################### ############## Hardware configurations ############################ #################################################################### configs.device = torch.device('cpu' if configs.no_cuda else 'cuda') configs.ngpus_per_node = torch.cuda.device_count() configs.pin_memory = True #################################################################### ############## Data configs ################### #################################################################### configs.working_dir = '../../' configs.dataset_dir = os.path.join(configs.working_dir, 'dataset') configs.train_game_list = [ 'game_1', 'game_2', 'game_3', 'game_4', 'game_5' ] configs.test_game_list = [ 'test_1', 'test_2', 'test_3', 'test_4', 'test_5', 'test_6', 'test_7' ] configs.events_dict = {'bounce': 0, 'net': 1, 'empty_event': 2} configs.events_weights_loss_dict = { 'bounce': 1., 'net': 3., } configs.events_weights_loss = (configs.events_weights_loss_dict['bounce'], configs.events_weights_loss_dict['net']) configs.num_events = len( configs.events_weights_loss_dict) # Just "bounce" and "net hits" configs.num_frames_sequence = 9 configs.input_size = (320, 128) configs.tasks = ['global', 'local', 'event', 'seg'] if configs.no_local: if 'local' in configs.tasks: configs.tasks.remove('local') if 'event' in configs.tasks: configs.tasks.remove('event') if configs.no_event: if 'event' in configs.tasks: configs.tasks.remove('event') if configs.no_seg: if 'seg' in configs.tasks: configs.tasks.remove('seg') # Compose loss weight for tasks, normalize the weights later loss_weight_dict = { 'global': configs.global_weight, 'local': configs.local_weight, 'event': configs.event_weight, 'seg': configs.seg_weight } configs.tasks_loss_weight = [] for task in configs.tasks: configs.tasks_loss_weight.append(loss_weight_dict[task]) configs.freeze_modules_list = [] if configs.freeze_global: configs.freeze_modules_list.append('ball_global_stage') if configs.freeze_local: configs.freeze_modules_list.append('ball_local_stage') if configs.freeze_event: configs.freeze_modules_list.append('events_spotting') if configs.freeze_seg: configs.freeze_modules_list.append('segmentation') #################################################################### ############## logs, Checkpoints, and results dir ######################## #################################################################### configs.checkpoints_dir = os.path.join(configs.working_dir, 'checkpoints', configs.saved_fn) configs.logs_dir = os.path.join(configs.working_dir, 'logs', configs.saved_fn) configs.use_best_checkpoint = True if configs.use_best_checkpoint: configs.saved_weight_name = os.path.join( configs.checkpoints_dir, '{}_best.pth'.format(configs.saved_fn)) else: configs.saved_weight_name = os.path.join( configs.checkpoints_dir, '{}.pth'.format(configs.saved_fn)) configs.results_dir = os.path.join(configs.working_dir, 'results') make_folder(configs.checkpoints_dir) make_folder(configs.logs_dir) make_folder(configs.results_dir) if configs.save_test_output: configs.saved_dir = os.path.join(configs.results_dir, configs.saved_fn) make_folder(configs.saved_dir) return configs
def parse_test_configs(): parser = argparse.ArgumentParser( description='Demonstration config for RTM3D Implementation') parser.add_argument('--saved_fn', type=str, default='rtm3d', metavar='FN', help='The name using for saving logs, models,...') parser.add_argument('-a', '--arch', type=str, default='resnet_18', metavar='ARCH', help='The name of the model architecture') parser.add_argument('--pretrained_path', type=str, default=None, metavar='PATH', help='the path of the pretrained checkpoint') parser.add_argument('--head_conv', type=int, default=-1, help='conv layer channels for output head' '0 for no conv layer' '-1 for default setting: ' '64 for resnets and 256 for dla.') parser.add_argument('--K', type=int, default=100, help='the number of top K') parser.add_argument('--use_left_cam_prob', type=float, default=1., help='The probability of using the left camera') parser.add_argument( '--dynamic-sigma', action='store_true', help='If true, compute sigma based on Amax, Amin then generate heamap' 'If false, compute radius as CenterNet did') parser.add_argument('--no_cuda', action='store_true', help='If true, cuda is not used.') parser.add_argument('--gpu_idx', default=None, type=int, help='GPU index to use.') parser.add_argument('--num_samples', type=int, default=None, help='Take a subset of the dataset to run and debug') parser.add_argument('--num_workers', type=int, default=1, help='Number of threads for loading data') parser.add_argument('--batch_size', type=int, default=1, help='mini-batch size (default: 4)') parser.add_argument('--peak_thresh', type=float, default=0.2) parser.add_argument('--show_image', action='store_true', help='If true, show the image during demostration') parser.add_argument( '--save_test_output', action='store_true', help='If true, the output image of the testing phase will be saved') parser.add_argument( '--output_format', type=str, default='image', metavar='PATH', help='the type of the test output (support image or video)') parser.add_argument( '--output_video_fn', type=str, default='out_rtm3d', metavar='PATH', help='the video filename if the output format is video') parser.add_argument('--show_3dbox', type=str, default=False, help='show 3D bounding box') configs = edict(vars(parser.parse_args())) configs.pin_memory = True configs.distributed = False # For testing on 1 GPU only configs.input_size = (384, 1280) configs.hm_size = (96, 320) configs.down_ratio = 4 configs.max_objects = 50 if configs.head_conv == -1: # init default head_conv configs.head_conv = 256 if 'dla' in configs.arch else 64 configs.num_classes = 3 configs.num_vertexes = 8 configs.num_center_offset = 2 configs.num_vertexes_offset = 2 configs.num_dimension = 3 configs.num_rot = 8 configs.num_depth = 1 configs.num_wh = 2 configs.heads = { 'hm_mc': configs.num_classes, 'hm_ver': configs.num_vertexes, 'vercoor': configs.num_vertexes * 2, 'cenoff': configs.num_center_offset, 'veroff': configs.num_vertexes_offset, 'dim': configs.num_dimension, 'rot': configs.num_rot, 'depth': configs.num_depth, 'wh': configs.num_wh } #################################################################### ##############Dataset, Checkpoints, and results dir configs######### #################################################################### configs.root_dir = '../' configs.dataset_dir = os.path.join(configs.root_dir, 'dataset', 'kitti') if configs.save_test_output: configs.results_dir = os.path.join(configs.root_dir, 'results', configs.saved_fn) make_folder(configs.results_dir) return configs
def parse_test_configs(): parser = argparse.ArgumentParser( description='Testing config for the Implementation') parser.add_argument('--saved_fn', type=str, default='fpn_resnet_18', metavar='FN', help='The name using for saving logs, models,...') parser.add_argument('-a', '--arch', type=str, default='fpn_resnet_18', metavar='ARCH', help='The name of the model architecture') parser.add_argument( '--pretrained_path', type=str, default='../checkpoints/fpn_resnet_18/fpn_resnet_18_epoch_300.pth', metavar='PATH', help='the path of the pretrained checkpoint') parser.add_argument('--K', type=int, default=50, help='the number of top K') parser.add_argument('--no_cuda', action='store_true', help='If true, cuda is not used.') parser.add_argument('--gpu_idx', default=0, type=int, help='GPU index to use.') parser.add_argument('--num_samples', type=int, default=None, help='Take a subset of the dataset to run and debug') parser.add_argument('--num_workers', type=int, default=1, help='Number of threads for loading data') parser.add_argument('--batch_size', type=int, default=1, help='mini-batch size (default: 4)') parser.add_argument('--peak_thresh', type=float, default=0.2) parser.add_argument( '--save_test_output', action='store_true', help='If true, the output image of the testing phase will be saved') parser.add_argument( '--output_format', type=str, default='image', metavar='PATH', help='the type of the test output (support image or video)') parser.add_argument( '--output_video_fn', type=str, default='out_fpn_resnet_18', metavar='PATH', help='the video filename if the output format is video') parser.add_argument( '--output-width', type=int, default=608, help='the width of showing output, the height maybe vary') configs = edict(vars(parser.parse_args())) configs.pin_memory = True configs.distributed = False # For testing on 1 GPU only configs.input_size = (432, 432) configs.hm_size = (216, 216) configs.down_ratio = 2 configs.max_objects = 50 configs.imagenet_pretrained = False configs.head_conv = 256 configs.num_classes = 1 configs.num_center_offset = 2 configs.num_z = 1 configs.num_dim = 3 configs.num_direction = 2 # sin, cos configs.voxel_size = [0.16, 0.16, 4] configs.point_cloud_range = [0, -34.56, -2.73, 69.12, 34.56, 1.27] configs.max_number_of_points_per_voxel = 100 configs.heads = { 'hm_cen': configs.num_classes, 'cen_offset': configs.num_center_offset, 'direction': configs.num_direction, 'z_coor': configs.num_z, 'dim': configs.num_dim } configs.num_input_features = 4 #################################################################### ##############Dataset, Checkpoints, and results dir configs######### #################################################################### configs.working_dir = '../' configs.dataset_dir = '/media/wx/File/data/kittidata' if configs.save_test_output: configs.results_dir = os.path.join(configs.working_dir, 'results', configs.saved_fn) make_folder(configs.results_dir) return configs
def parse_test_configs(): parser = argparse.ArgumentParser(description='Demonstration config for CenterNet3D Implementation') parser.add_argument('--saved_fn', type=str, default='centernet3d', metavar='FN', help='The name using for saving logs, models,...') parser.add_argument('-a', '--arch', type=str, default='centernet3d', metavar='ARCH', help='The name of the model architecture') parser.add_argument('--pretrained_path', type=str, default=None, metavar='PATH', help='the path of the pretrained checkpoint') parser.add_argument('--K', type=int, default=100, help='the number of top K') parser.add_argument('--no_cuda', action='store_true', help='If true, cuda is not used.') parser.add_argument('--gpu_idx', default=None, type=int, help='GPU index to use.') parser.add_argument('--num_samples', type=int, default=None, help='Take a subset of the dataset to run and debug') parser.add_argument('--num_workers', type=int, default=1, help='Number of threads for loading data') parser.add_argument('--batch_size', type=int, default=1, help='mini-batch size (default: 4)') parser.add_argument('--peak_thresh', type=float, default=0.2) parser.add_argument('--show_image', action='store_true', help='If true, show the image during demostration') parser.add_argument('--save_test_output', action='store_true', help='If true, the output image of the testing phase will be saved') parser.add_argument('--output_format', type=str, default='image', metavar='PATH', help='the type of the test output (support image or video)') parser.add_argument('--output_video_fn', type=str, default='out_centernet3d', metavar='PATH', help='the video filename if the output format is video') configs = edict(vars(parser.parse_args())) configs.pin_memory = True configs.distributed = False # For testing on 1 GPU only configs.sparse_shape = (40, 1400, 1600) configs.input_size = (1400, 1600) configs.hm_size = (350, 400) configs.down_ratio = 4 configs.max_objects = 50 configs.head_conv = 64 configs.num_classes = 1 configs.num_center_offset = 2 configs.num_z = 1 configs.num_dim = 3 configs.num_direction = 2 # sin, cos configs.num_conners = 4 configs.heads = { 'hm_cen': configs.num_classes, 'cen_offset': configs.num_center_offset, 'direction': configs.num_direction, 'z_coor': configs.num_z, 'dim': configs.num_dim, 'hm_conners': configs.num_classes # equal classes --> 3 } configs.num_input_features = 4 #################################################################### ##############Dataset, Checkpoints, and results dir configs######### #################################################################### configs.root_dir = '../' configs.dataset_dir = os.path.join(configs.root_dir, 'dataset', 'kitti') if configs.save_test_output: configs.results_dir = os.path.join(configs.root_dir, 'results', configs.saved_fn) make_folder(configs.results_dir) return configs
def parse_configs(): parser = argparse.ArgumentParser(description='The Implementation of Complex YOLOv4') parser.add_argument('--seed', type=int, default=2020, help='re-produce the results with seed random') parser.add_argument('--saved_fn', type=str, default='complexer_yolo', metavar='FN', help='The name using for saving logs, models,...') #################################################################### ############## Model configs ######################## #################################################################### parser.add_argument('-a', '--arch', type=str, default='darknet', metavar='ARCH', help='The name of the model architecture') parser.add_argument('--cfgfile', type=str, default='config/complex_yolov4.cfg', metavar='PATH', help='The path for cfgfile (only for darknet)') parser.add_argument('--pretrained_path', type=str, default=None, metavar='PATH', help='the path of the pretrained checkpoint') #################################################################### ############## Dataloader and Running configs ####### #################################################################### parser.add_argument('--img_size', type=int, default=608, help='the size of input image') parser.add_argument('--multiscale_training', action='store_true', help='If true, use scaling data for training') parser.add_argument('--no-val', action='store_true', help='If true, dont evaluate the model on the val set') parser.add_argument('--num_samples', type=int, default=None, help='Take a subset of the dataset to run and debug') parser.add_argument('--num_workers', type=int, default=8, help='Number of threads for loading data') parser.add_argument('--batch_size', type=int, default=4, help='mini-batch size (default: 4), this is the total' 'batch size of all GPUs on the current node when using' 'Data Parallel or Distributed Data Parallel') parser.add_argument('--subdivisions', type=int, default=16, help='subdivisions during training') parser.add_argument('--print_freq', type=int, default=50, metavar='N', help='print frequency (default: 50)') parser.add_argument('--tensorboard_freq', type=int, default=20, metavar='N', help='frequency of saving tensorboard (default: 20)') parser.add_argument('--checkpoint_freq', type=int, default=2, metavar='N', help='frequency of saving checkpoints (default: 2)') #################################################################### ############## Training strategy #################### #################################################################### parser.add_argument('--start_epoch', type=int, default=1, metavar='N', help='the starting epoch') parser.add_argument('--num_epochs', type=int, default=300, metavar='N', help='number of total epochs to run') parser.add_argument('--lr', type=float, default=0.0025, metavar='LR', help='initial learning rate') parser.add_argument('--minimum_lr', type=float, default=1e-7, metavar='MIN_LR', help='minimum learning rate during training') parser.add_argument('--momentum', type=float, default=0.949, metavar='M', help='momentum') parser.add_argument('-wd', '--weight_decay', type=float, default=5e-4, metavar='WD', help='weight decay (default: 1e-6)') parser.add_argument('--optimizer_type', type=str, default='adam', metavar='OPTIMIZER', help='the type of optimizer, it can be sgd or adam') parser.add_argument('--burn_in', type=int, default=50, metavar='N', help='number of burn in step') parser.add_argument('--steps', nargs='*', default=[1500, 4000], help='number of burn in step') #################################################################### ############## Loss weight ########################## #################################################################### #################################################################### ############## Distributed Data Parallel ############ #################################################################### parser.add_argument('--world-size', default=-1, type=int, metavar='N', help='number of nodes for distributed training') parser.add_argument('--rank', default=-1, type=int, metavar='N', help='node rank for distributed training') parser.add_argument('--dist-url', default='tcp://127.0.0.1:29500', type=str, help='url used to set up distributed training') parser.add_argument('--dist-backend', default='nccl', type=str, help='distributed backend') parser.add_argument('--gpu_idx', default=None, type=int, help='GPU index to use.') parser.add_argument('--no_cuda', action='store_true', help='If true, cuda is not used.') parser.add_argument('--multiprocessing-distributed', action='store_true', help='Use multi-processing distributed training to launch ' 'N processes per node, which has N GPUs. This is the ' 'fastest way to use PyTorch for either single node or ' 'multi node data parallel training') #################################################################### ############## Evaluation configurations ################### #################################################################### parser.add_argument('--evaluate', action='store_true', help='only evaluate the model, not training') parser.add_argument('--resume_path', type=str, default=None, metavar='PATH', help='the path of the resumed checkpoint') configs = edict(vars(parser.parse_args())) #################################################################### ############## Hardware configurations ############################# #################################################################### configs.device = torch.device('cpu' if configs.no_cuda else 'cuda') configs.ngpus_per_node = torch.cuda.device_count() configs.pin_memory = True #################################################################### ############## Dataset, logs, Checkpoints dir ###################### #################################################################### configs.working_dir = '../' configs.dataset_dir = os.path.join(configs.working_dir, 'dataset', 'kitti') configs.checkpoints_dir = os.path.join(configs.working_dir, 'checkpoints', configs.saved_fn) configs.logs_dir = os.path.join(configs.working_dir, 'logs', configs.saved_fn) make_folder(configs.checkpoints_dir) make_folder(configs.logs_dir) return configs
def parse_test_configs(): parser = argparse.ArgumentParser( description='Demonstration config for Complex YOLO Implementation') parser.add_argument('--saved_fn', type=str, default='complexer_yolov4', metavar='FN', help='The name using for saving logs, models,...') parser.add_argument('-a', '--arch', type=str, default='darknet', metavar='ARCH', help='The name of the model architecture') parser.add_argument('--cfgfile', type=str, default='./config/cfg/complex_yolov4.cfg', metavar='PATH', help='The path for cfgfile (only for darknet)') parser.add_argument('--pretrained_path', type=str, default=None, metavar='PATH', help='the path of the pretrained checkpoint') parser.add_argument( '--use_giou_loss', action='store_true', help= 'If true, use GIoU loss during training. If false, use MSE loss for training' ) parser.add_argument('--no_cuda', action='store_true', help='If true, cuda is not used.') parser.add_argument('--gpu_idx', default=None, type=int, help='GPU index to use.') parser.add_argument('--img_size', type=int, default=608, help='the size of input image') parser.add_argument('--num_samples', type=int, default=None, help='Take a subset of the dataset to run and debug') parser.add_argument('--num_workers', type=int, default=1, help='Number of threads for loading data') parser.add_argument('--batch_size', type=int, default=1, help='mini-batch size (default: 4)') parser.add_argument('--conf_thresh', type=float, default=0.5, help='the threshold for conf') parser.add_argument('--nms_thresh', type=float, default=0.5, help='the threshold for conf') parser.add_argument('--show_image', action='store_true', help='If true, show the image during demostration') parser.add_argument( '--save_test_output', action='store_true', help='If true, the output image of the testing phase will be saved') parser.add_argument( '--output_format', type=str, default='image', metavar='PATH', help='the type of the test output (support image or video)') parser.add_argument( '--output_video_fn', type=str, default='out_complexer_yolov4', metavar='PATH', help='the video filename if the output format is video') # added these # parser.add_argument('--hflip_prob', type=float, default=0.5, # help='The probability of horizontal flip') # parser.add_argument('--cutout_nholes', type=int, default=1, # help='The number of cutout area') # parser.add_argument('--cutout_ratio', type=float, default=0.3, # help='The max ratio of the cutout area') # parser.add_argument('--cutout_fill_value', type=float, default=0., # help='The fill value in the cut out area, default 0. (black)') # parser.add_argument('--cutout_prob', type=float, default=0., # help='The probability of cutout augmentation') # parser.add_argument('--multiscale_training', action='store_true', # help='If true, use scaling data for training') # parser.add_argument('--mosaic', action='store_true', # help='If true, compose training samples as mosaics') # parser.add_argument('--random-padding', action='store_true', # help='If true, random padding if using mosaic augmentation') configs = edict(vars(parser.parse_args())) configs.pin_memory = True #################################################################### ##############Dataset, Checkpoints, and results dir configs######### #################################################################### configs.working_dir = './' configs.dataset_dir = os.path.join(configs.working_dir, 'dataset') print('ls :', os.listdir(configs.working_dir)) if configs.save_test_output: configs.results_dir = os.path.join(configs.working_dir, 'results', configs.saved_fn) make_folder(configs.results_dir) return configs