コード例 #1
0
    def __init__(self, gpu_id=0, model_path=None):
        self.cfg_file = '${PGPT_ROOT}/cfgs/pose_res152.yaml'
        self.flag = 0

        update_config(self.cfg_file)
        print('----------------------------------------')
        print('PoseEstimation: Initilizing pose estimation network...')
        self.gpu_id = gpu_id
        self.pixel_std = 200
        self.image_size = cfg.MODEL.IMAGE_SIZE
        self.image_width = self.image_size[0]
        self.image_height = self.image_size[1]
        self.aspect_ratio = self.image_width * 1.0 / self.image_height
        self.transform = transforms.Compose([
            transforms.ToTensor(),
            transforms.Normalize(mean=[0.485, 0.456, 0.406],
                                 std=[0.229, 0.224, 0.225])
        ])
        self.flip_pairs = [[5, 6], [7, 8], [9, 10], [11, 12], [13, 14],
                           [15, 16]]

        cfg.TEST.FLIP_TEST = True
        cfg.TEST.POST_PROCESS = True
        cfg.TEST.SHIFT_HEATMAP = True
        cfg.TEST.MODEL_FILE = model_path

        torch.backends.cudnn.deterministic = cfg.CUDNN.DETERMINISTIC
        torch.backends.cudnn.enabled = cfg.CUDNN.ENABLED

        with torch.cuda.device(self.gpu_id):
            self.model = get_pose_net(cfg, is_train=False, flag=self.flag)
            self._load_model()
            self.model.eval()
コード例 #2
0
	def __init__(self, gpu_id=0, model_path='/export/home/zby/SiamFC/data/models/model_99.pth.tar'):
		self.cfg_file='/export/home/zby/SiamFC/cfgs/pose_res152.yaml'
		self.flag = 0

		update_config(self.cfg_file)
		print('----------------------------------------')
		print('PoseEstimation: Initilizing pose estimation network...')
		self.gpu_id = gpu_id
		self.pixel_std = 200
		self.image_size = cfg.MODEL.IMAGE_SIZE
		self.image_width = self.image_size[0]
		self.image_height = self.image_size[1]
		self.aspect_ratio = self.image_width * 1.0 /self.image_height
		self.transform = transforms.Compose([transforms.ToTensor(),
											 transforms.Normalize(mean = [0.485,0.456,0.406],
																  std = [0.229,0.224,0.225])
											])		
		self.flip_pairs = [[5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]]

		cfg.TEST.FLIP_TEST = True
		cfg.TEST.POST_PROCESS = True
		cfg.TEST.SHIFT_HEATMAP = True
		cfg.TEST.MODEL_FILE = model_path

		#cudnn.benchmark = cfg.CUDNN.BENCHMARK
		torch.backends.cudnn.deterministic = cfg.CUDNN.DETERMINISTIC
		torch.backends.cudnn.enabled = cfg.CUDNN.ENABLED

		with torch.cuda.device(self.gpu_id):
			self.model = get_pose_net(cfg, is_train=False, flag = self.flag)
			#logger, final_output_dir, tb_log_dir = create_logger(cfg, cfg_file, 'valid')
			#logger.info(pprint.pformat(cfg))
			self._load_model()
			self.model.eval()
コード例 #3
0
def parse_args():
    parser = argparse.ArgumentParser(description='Train keypoints network')
    # general
    parser.add_argument(
        '--cfg',
        help='experiment configure file name',
        required=False,
        default='/export/home/zby/SiamFC/data/pose_res152.yaml',
        type=str)

    args, rest = parser.parse_known_args()
    # update config
    update_config(args.cfg)

    # training
    parser.add_argument('--frequent',
                        help='frequency of logging',
                        default=config.PRINT_FREQ,
                        type=int)
    parser.add_argument('--gpus', help='gpus', type=str, default='0')
    parser.add_argument('--workers',
                        help='num of dataloader workers',
                        type=int)
    parser.add_argument('--model-file',
                        help='model state file',
                        default='data/models/model_99.pth.tar',
                        type=str)
    parser.add_argument('--use-detect-bbox',
                        help='use detect bbox',
                        action='store_true')
    parser.add_argument('--flip-test',
                        help='use flip test',
                        action='store_true',
                        default=True)
    parser.add_argument('--post-process',
                        help='use post process',
                        action='store_true')
    parser.add_argument('--shift-heatmap',
                        help='shift heatmap',
                        action='store_true')
    parser.add_argument('--coco-bbox-file',
                        help='coco detection bbox file',
                        type=str)

    args = parser.parse_args()

    return args
コード例 #4
0
    def __init__(
            self,
            data_path,
            annotation_path,
            num_video,
            gpu_id=0,
            model_path='/export/home/zby/SiamFC/data/models/final_new.pth.tar'
    ):
        self.cfg_file = '/export/home/zby/SiamFC/cfgs/pose_res152.yaml'
        update_config(self.cfg_file)
        self.data_path = data_path
        self.annotation_path = annotation_path
        self.num_video = num_video
        print('----------------------------------------')
        print('Pose & Embedding: Initilizing pose & embedding network...')
        #self.test_thresh_list = [0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18 ,0.19, 0.2]
        self.test_thresh_list = [
            0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2,
            0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 1
        ]
        self.gpu_id = gpu_id
        self.pixel_std = 200
        self.image_size = cfg.MODEL.IMAGE_SIZE
        self.image_width = self.image_size[0]
        self.image_height = self.image_size[1]
        self.aspect_ratio = self.image_width * 1.0 / self.image_height
        self.transform = transforms.Compose([
            transforms.ToTensor(),
            transforms.Normalize(mean=[0.485, 0.456, 0.406],
                                 std=[0.229, 0.224, 0.225])
        ])
        cfg.TEST.FLIP_TEST = True
        cfg.TEST.POST_PROCESS = True
        cfg.TEST.SHIFT_HEATMAP = True
        cfg.TEST.MODEL_FILE = model_path

        #cudnn.benchmark = cfg.CUDNN.BENCHMARK
        torch.backends.cudnn.deterministic = cfg.CUDNN.DETERMINISTIC
        torch.backends.cudnn.enabled = cfg.CUDNN.ENABLED

        with torch.cuda.device(self.gpu_id):
            self.model = get_pose_net(cfg, is_train=False)
            self._load_model()
            self.model.eval()
        print('Pose & Embedding: Test thresh list is set as {}'.format(
            self.test_thresh_list))
コード例 #5
0
	def __init__(self, gpu_id, train=True):
		self.cfg_file='/export/home/zby/SiamFC/cfgs/pose_res152.yaml'
		update_config(self.cfg_file)
		super(SiameseAlexNet, self).__init__()
		self.PoseNet = get_pose_net(cfg, is_train=False, flag = 4)
		self.exemplar_size = (8,8)
		self.multi_instance_size = [(24,24),(22,22)]
		
		self.features = nn.Sequential(
			nn.Conv2d(3, 96, 11, 2),
			nn.BatchNorm2d(96),
			nn.ReLU(inplace=True),
			nn.MaxPool2d(3, 2),
			nn.Conv2d(96, 256, 5, 1, groups=2),
			nn.BatchNorm2d(256),
			nn.ReLU(inplace=True),
			nn.MaxPool2d(3, 2),
			nn.Conv2d(256, 384, 3, 1),
			nn.BatchNorm2d(384),
			nn.ReLU(inplace=True),
			nn.Conv2d(384, 384, 3, 1, groups=2),
			nn.BatchNorm2d(384),
			nn.ReLU(inplace=True))
			
		self.conv_pose = nn.Conv2d(2048, 384, 3, 1, padding=1)
		self.conv_final = nn.Conv2d(384, 256, 3, 1, groups=2)
		
		self.corr_bias = nn.Parameter(torch.zeros(1))
		if train:
			gt, weight = self._create_gt_mask((config.train_response_sz, config.train_response_sz),mode='train')
			with torch.cuda.device(gpu_id):
				self.train_gt = torch.from_numpy(gt).cuda()
				self.train_weight = torch.from_numpy(weight).cuda()
			gt, weight = self._create_gt_mask((config.response_sz, config.response_sz), mode='valid')
			with torch.cuda.device(gpu_id):
				self.valid_gt = torch.from_numpy(gt).cuda()
				self.valid_weight = torch.from_numpy(weight).cuda()
		self.exemplar = None