parser.add_argument( "--coco", help="Do test on COCOPersons val set", action="store_true", ) parser.add_argument( "--benchmark", help="Do fps test without warpaffine", action="store_true", ) parser.add_argument( "--OCHuman", help="Do test on OCHuman val&test set", action="store_true", ) args = parser.parse_args() jt.flags.use_cuda = 1 print('===========> loading model <===========') model = Pose2Seg() model.init(args.weights) model.benchmark = args.benchmark print('===========> testing <===========') if args.coco: test(model, dataset='cocoVal', benchmark=args.benchmark) if args.OCHuman: test(model, dataset='OCHumanVal', benchmark=args.benchmark) test(model, dataset='OCHumanTest', benchmark=args.benchmark)
cocoEval.evaluate() cocoEval.accumulate() cocoEval.summarize() return cocoEval cocoEval = do_eval_coco(imgIds, datainfos.COCO, results_segm, 'segm') logger('[POSE2SEG] AP|.5|.75| S| M| L| AR|.5|.75| S| M| L|') _str = '[segm_score] %s '%dataset for value in cocoEval.stats.tolist(): _str += '%.3f '%value logger(_str) if __name__=='__main__': model_path = './pose2seg_release.pkl' print('===========> loading model <===========') model = Pose2Seg().cuda() model.init(model_path) model.eval() ImageRoot = './data/images' AnnoFile = './data/person_keypoints_val2017_pose2seg.json' datainfos = CocoDatasetInfo(ImageRoot, AnnoFile, onlyperson=True, loadimg=True) model.eval() results_segm = [] imgIds = [] for i in tqdm(range(len(datainfos))): rawdata = datainfos[i] g1 = np.float32(rawdata['gt_keypoints']) g2 = np.float32(rawdata['gt_keypoints']).transpose(0, 2, 1)
cur_canvas = canvas.copy() cv2.fillConvexPoly(cur_canvas, polygon, colors[idx % len(colors)]) canvas = cv2.addWeighted(canvas, 0.4, cur_canvas, 0.6, 0) return canvas # Namespace(OCHuman=True, coco=True, weights='last.pkl') cfg = AttrDict() cfg.OCHuman = True cfg.coco = True cfg.weights = '/nethome/hkwon64/Research/imuTube/repos_v2/human_parsing/Pose2Seg/log/pose2seg_release.pkl' device = torch.device('cuda', 1) model = Pose2Seg(device).to(device) model.init(cfg.weights) model.eval() dir_save = '/nethome/hkwon64/Research/imuTube/repos_v2/human_parsing/Pose2Seg/demo' file_im = dir_save + '/demo.jpg' file_ap = dir_save + '/alphapose-results.json' ap_result = json.load(open(file_ap, 'r')) gt_bbox = [] gt_kpts = [] for result in ap_result: x1, y1, w, h = result['box'] bbox = int(x1), int(y1), int(x1 + w), int(y1 + h) gt_bbox.append(bbox)