Ejemplo n.º 1
0
def main():
    # Get args from command line
    args = get_args_from_command_line()

    if args.gpu_id is not None:
        cfg.CONST.DEVICE = args.gpu_id
    if args.weights is not None:
        cfg.CONST.WEIGHTS = args.weights

    # Print config
    print('Use config:')
    pprint(cfg)

    # Set GPU to use
    os.environ["CUDA_VISIBLE_DEVICES"] = cfg.CONST.DEVICE

    # Start train/test process
    if not args.test and not args.inference:
        train_net_new(cfg)
    else:
        if 'WEIGHTS' not in cfg.CONST or not os.path.exists(cfg.CONST.WEIGHTS):
            logging.error('Please specify the file path of checkpoint.')
            sys.exit(2)

        if args.test:
            test_net_new(cfg)
        else:
            inference_net(cfg)
Ejemplo n.º 2
0
 def inference(self):
     self.makeCurrent()
     pc_points = inference_net(cfg, upload_image=False)
     GM.base_point_cloud = PointCloud(pc_points)
     GM.base_point_cloud.set_color_according_camera_pos(
         camera_pos=[1.5, 1.5, 0.0])
     self.update()
Ejemplo n.º 3
0
def main():
    # Get args from command line
    args = get_args_from_command_line()

    if args.gpu_id is not None:
        cfg.CONST.DEVICE = args.gpu_id
    if args.weights is not None:
        cfg.CONST.WEIGHTS = args.weights

    # Print config
    print('Use config:')
    pprint(cfg)
    # f_runner.write(str(cfg))

    # Set GPU to use
    os.environ["CUDA_VISIBLE_DEVICES"] = cfg.CONST.DEVICE

    # Start train/test process
    if not args.test and not args.inference:
        train_net(cfg)
    else:
        '''
        if 'WEIGHTS' not in cfg.CONST or not os.path.exists(cfg.CONST.WEIGHTS):
            logging.error('Please specify the file path of checkpoint.')
            sys.exit(2)
        '''

        if 'WEIGHTS' not in cfg.CONST:
            logging.error('Please specify the file path of checkpoint.1')
            sys.exit(2)
        if not os.path.exists(cfg.CONST.WEIGHTS):
            logging.error('Please specify the file path of checkpoint.2')
            sys.exit(2)

        if args.test:
            # test_net(cfg)
            path = '/raid/wuruihai/GRNet_FILES/tb_log'
            test_writer = SummaryWriter(path)
            test_net(cfg, test_writer=test_writer)

        if args.test_KITTI:
            path = '/raid/wuruihai/GRNet_FILES/tb_log'
            test_writer = SummaryWriter(path)
            test_net_KITTI(cfg, test_writer=test_writer)
        else:
            inference_net(cfg)
Ejemplo n.º 4
0
def main():
    # Get args from command line
    args = get_args_from_command_line()

    # Read the experimental config
    exec(compile(open(args.cfg_file, "rb").read(), args.cfg_file, 'exec'))
    cfg = locals()['__C']
    pprint(cfg)

    # Parse runtime arguments
    if args.gpu_id is not None:
        os.environ["CUDA_VISIBLE_DEVICES"] = args.gpu_id
    if not args.randomize:
        random.seed(cfg.CONST.RNG_SEED)
        np.random.seed(cfg.CONST.RNG_SEED)
        torch.manual_seed(cfg.CONST.RNG_SEED)
        torch.cuda.manual_seed(cfg.CONST.RNG_SEED)
        torch.cuda.manual_seed_all(cfg.CONST.RNG_SEED)
        # References: https://pytorch.org/docs/stable/notes/randomness.html
        torch.backends.cudnn.deterministic = True
        torch.backends.cudnn.benchmark = False
    if args.exp_name is not None:
        cfg.CONST.EXP_NAME = args.exp_name
    if args.weights is not None:
        cfg.CONST.WEIGHTS = args.weights

    # Start train/test process
    if not args.test and not args.inference:
        # Make sure cfg.TRAIN.NETWORK in ['RMNet', 'TinyFlowNet']
        if cfg.TRAIN.NETWORK not in ['RMNet', 'TinyFlowNet']:
            logging.error(
                'Please make sure cfg.TRAIN.NETWORK in ["RMNet", "TinyFlowNet"].'
            )
            sys.exit(1)

        train_net(cfg)
    else:
        if 'WEIGHTS' not in cfg.CONST or not os.path.exists(cfg.CONST.WEIGHTS):
            logging.error('Please specify the file path of checkpoint.')
            sys.exit(2)

        if args.test:
            test_net(cfg)
        else:
            inference_net(cfg)