def im_detect_all(model, im, box_proposals, timers=None): if timers is None: timers = defaultdict(Timer) # Handle RetinaNet testing separately for now if cfg.RETINANET.RETINANET_ON: cls_boxes = test_retinanet.im_detect_bbox(model, im, timers) return cls_boxes, None, None timers['im_detect_bbox'].tic() if cfg.TEST.BBOX_AUG.ENABLED: scores, boxes, im_scale = im_detect_bbox_aug(model, im, box_proposals) else: # import pdb # pdb.set_trace() scores, boxes, im_scale = im_detect_bbox(model, im, cfg.TEST.SCALE, cfg.TEST.MAX_SIZE, boxes=box_proposals) timers['im_detect_bbox'].toc() # score and boxes are from the whole image after score thresholding and nms # (they are not separated by class) # cls_boxes boxes and scores are separated by class and in the format used # for evaluating results timers['misc_bbox'].tic() scores, boxes, cls_boxes = box_results_with_nms_and_limit(scores, boxes) timers['misc_bbox'].toc() if cfg.MODEL.MASK_ON and boxes.shape[0] > 0: timers['im_detect_mask'].tic() if cfg.TEST.MASK_AUG.ENABLED: masks = im_detect_mask_aug(model, im, boxes) else: masks = im_detect_mask(model, im_scale, boxes) timers['im_detect_mask'].toc() timers['misc_mask'].tic() cls_segms = segm_results(cls_boxes, masks, boxes, im.shape[0], im.shape[1]) timers['misc_mask'].toc() else: cls_segms = None if cfg.MODEL.KEYPOINTS_ON and boxes.shape[0] > 0: timers['im_detect_keypoints'].tic() if cfg.TEST.KPS_AUG.ENABLED: heatmaps = im_detect_keypoints_aug(model, im, boxes) else: heatmaps = im_detect_keypoints(model, im_scale, boxes) timers['im_detect_keypoints'].toc() timers['misc_keypoints'].tic() cls_keyps = keypoint_results(cls_boxes, heatmaps, boxes) timers['misc_keypoints'].toc() else: cls_keyps = None return cls_boxes, cls_segms, cls_keyps
def im_detect_all(model, im, box_proposals, timers=None): if timers is None: timers = defaultdict(Timer) # Handle RetinaNet testing separately for now if cfg.RETINANET.RETINANET_ON: cls_boxes = test_retinanet.im_detect_bbox(model, im, timers) return cls_boxes, None, None timers['im_detect_bbox'].tic() if cfg.TEST.BBOX_AUG.ENABLED: scores, boxes, im_scale = im_detect_bbox_aug(model, im, box_proposals) else: scores, boxes, im_scale = im_detect_bbox( model, im, cfg.TEST.SCALE, cfg.TEST.MAX_SIZE, boxes=box_proposals ) timers['im_detect_bbox'].toc() # score and boxes are from the whole image after score thresholding and nms # (they are not separated by class) # cls_boxes boxes and scores are separated by class and in the format used # for evaluating results timers['misc_bbox'].tic() scores, boxes, cls_boxes = box_results_with_nms_and_limit(scores, boxes) timers['misc_bbox'].toc() if cfg.MODEL.MASK_ON and boxes.shape[0] > 0: timers['im_detect_mask'].tic() if cfg.TEST.MASK_AUG.ENABLED: masks = im_detect_mask_aug(model, im, boxes) else: masks = im_detect_mask(model, im_scale, boxes) timers['im_detect_mask'].toc() timers['misc_mask'].tic() cls_segms = segm_results( cls_boxes, masks, boxes, im.shape[0], im.shape[1] ) timers['misc_mask'].toc() else: cls_segms = None if cfg.MODEL.KEYPOINTS_ON and boxes.shape[0] > 0: timers['im_detect_keypoints'].tic() if cfg.TEST.KPS_AUG.ENABLED: heatmaps = im_detect_keypoints_aug(model, im, boxes) else: heatmaps = im_detect_keypoints(model, im_scale, boxes) timers['im_detect_keypoints'].toc() timers['misc_keypoints'].tic() cls_keyps = keypoint_results(cls_boxes, heatmaps, boxes) timers['misc_keypoints'].toc() else: cls_keyps = None return cls_boxes, cls_segms, cls_keyps
def im_detect_all(model, im, box_proposals, timers=None, model1=None): """the main function to run Net""" if timers is None: timers = defaultdict(Timer) # Handle RetinaNet testing separately for now if cfg.RETINANET.RETINANET_ON: cls_boxes = test_retinanet.im_detect_bbox(model, im, timers, model1) return cls_boxes, None, None timers['im_detect_bbox'].tic() if cfg.TEST.BBOX_AUG.ENABLED: # TODO: add multi-batch for this function scores, boxes, im_scale = im_detect_bbox_aug(model, im, box_proposals) else: scores, boxes, im_scale, batch_indices = im_detect_bbox( model, im, cfg.TEST.SCALE, cfg.TEST.MAX_SIZE, cfg.TEST.SIZEFIX, timers, model1, boxes=box_proposals) timers['im_detect_bbox'].toc() # score and boxes are from the whole image after score thresholding and nms # (they are not separated by class) # cls_boxes boxes and scores are separated by class and in the format used # for evaluating results timers['misc_bbox'].tic() cls_boxes_list = [] batch_cls_boxes = [] batch_size = int(max(batch_indices) + 1) for i in range(batch_size): idx = (batch_indices == i) per_image_scores = scores[idx, :] per_image_boxes = boxes[idx, :] per_image_scores, per_image_boxes, per_image_cls_boxes = \ box_results_with_nms_and_limit(per_image_scores, per_image_boxes) cls_boxes_list.append(per_image_cls_boxes) if i == 0: batch_scores = per_image_scores batch_boxes = per_image_boxes batch_cls_boxes = per_image_cls_boxes else: batch_scores = np.hstack((batch_scores, per_image_scores)) batch_boxes = np.vstack((batch_boxes, per_image_boxes)) batch_cls_boxes.extend(per_image_cls_boxes) scores = batch_scores boxes = batch_boxes cls_boxes = batch_cls_boxes timers['misc_bbox'].toc() if cfg.MODEL.MASK_ON and boxes.shape[0] > 0: timers['im_detect_mask'].tic() if cfg.TEST.MASK_AUG.ENABLED: masks = im_detect_mask_aug(model, im, boxes) else: masks = im_detect_mask(model, im_scale, boxes, timers) timers['im_detect_mask'].toc() timers['misc_mask'].tic() cls_segms = segm_results(cls_boxes, masks, boxes, im[0].shape[0], im[0].shape[1], batch_size) timers['misc_mask'].toc() else: cls_segms = None if cfg.MODEL.KEYPOINTS_ON and boxes.shape[0] > 0: timers['im_detect_keypoints'].tic() if cfg.TEST.KPS_AUG.ENABLED: heatmaps = im_detect_keypoints_aug(model, im, boxes) else: heatmaps = im_detect_keypoints(model, im_scale, boxes) timers['im_detect_keypoints'].toc() timers['misc_keypoints'].tic() cls_keyps = keypoint_results(cls_boxes, heatmaps, boxes) timers['misc_keypoints'].toc() else: cls_keyps = None return cls_boxes_list, cls_segms, cls_keyps
def im_detect_all(model, im, box_proposals, timers=None, im_path=None): if timers is None: timers = defaultdict(Timer) # Handle RetinaNet testing separately for now if cfg.RETINANET.RETINANET_ON: cls_boxes = test_retinanet.im_detect_bbox(model, im, timers) return cls_boxes, None, None timers['im_detect_bbox'].tic() # np.set_printoptions(threshold='nan') if cfg.TEST.BBOX_AUG.ENABLED: scores, boxes, im_scale = im_detect_bbox_aug(model, im, box_proposals) else: scores, boxes, im_scale = im_detect_bbox( model, im, cfg.TEST.SCALE, cfg.TEST.MAX_SIZE, boxes=box_proposals ) timers['im_detect_bbox'].toc() import matplotlib.pyplot as plt im_plt = im[:,:,(2,1,0)] print (boxes.shape) j =1 inds = np.where(scores[:, j] > 0.05)[0] scores_j = scores[inds, j] boxes_j = boxes[inds, j * 4:(j + 1) * 4] print(boxes_j.shape) plt.cla() plt.subplot(1,2,1) plt.imshow(im_plt) for i in range(boxes_j.shape[0]): # plt.gca().add_patch(plt.Rectangle((boxes[i][4], boxes[i][5] ), \ # boxes[i][6] - boxes[i][4], boxes[i][7] - boxes[i][5], \ # fill=False, edgecolor='r', linewidth=1)) # plt.gca().add_patch(plt.Circle((boxes_j[i][4], boxes_j[i][5]), 1, edgecolor='b', fill=True, linewidth=2)) # plt.gca().add_patch(plt.Circle((boxes_j[i][6], boxes_j[i][7]), 1, edgecolor='r', fill=True, linewidth=2)) plt.gca().add_patch(plt.Circle((boxes_j[i][0], boxes_j[i][1]), 1, edgecolor='b', fill=True, linewidth=2)) plt.gca().add_patch(plt.Circle((boxes_j[i][2], boxes_j[i][3]), 1, edgecolor='r', fill=True, linewidth=2)) anno_name = 'anno/gt_' + (im_path.split('/')[-1]).split('.')[0] + '.txt' anno_file = im_path.replace(im_path.split('/')[-1], anno_name) print(anno_file) gt_file = open(anno_file, 'r') gt_lines = gt_file.readlines() gt_file.close() plt.subplot(1,2,2) plt.imshow(im_plt) for line in gt_lines: if '\xef\xbb\xbf' in line: line = line.replace('\xef\xbb\xbf','') word = line.split(',')[-1] if word != '###\r\n': print(word) str_points = line.split(',')[:8] points = map(int, str_points) for i in range(4): plt.gca().add_patch(plt.Circle((points[i*2], points[i*2 + 1]), 1, edgecolor='r', fill=True, linewidth=3)) plt.show() print('======') # score and boxes are from the whole image after score thresholding and nms # (they are not separated by class) # cls_boxes boxes and scores are separated by class and in the format used # for evaluating results timers['misc_bbox'].tic() scores, boxes, cls_boxes = box_results_with_nms_and_limit(scores, boxes) timers['misc_bbox'].toc() # import matplotlib.pyplot as plt # im_plt = im[:,:,(2,1,0)] # plt.cla() # plt.subplot(1,2,1) # plt.imshow(im_plt) # for i in range(boxes.shape[0]): # plt.gca().add_patch(plt.Rectangle((boxes[i][0], boxes[i][1] ), \ # boxes[i][2] - boxes[i][0], boxes[i][3] - boxes[i][1], \ # fill=False, edgecolor='r', linewidth=1)) # anno_name = 'anno/gt_' + (im_path.split('/')[-1]).split('.')[0] + '.txt' # anno_file = im_path.replace(im_path.split('/')[-1], anno_name) # print(anno_file) # gt_file = open(anno_file, 'r') # gt_lines = gt_file.readlines() # gt_file.close() # plt.subplot(1,2,2) # plt.imshow(im_plt) # for line in gt_lines: # if '\xef\xbb\xbf' in line: # line = line.replace('\xef\xbb\xbf','') # word = line.split(',')[-1] # if word != '###\r\n': # print(word) # str_points = line.split(',')[:8] # points = map(int, str_points) # for i in range(4): # plt.gca().add_patch(plt.Circle((points[i*2], points[i*2 + 1]), 1, edgecolor='r', fill=True, linewidth=2)) # plt.show() # print('======') if cfg.MODEL.MASK_ON and boxes.shape[0] > 0: timers['im_detect_mask'].tic() if cfg.TEST.MASK_AUG.ENABLED: masks = im_detect_mask_aug(model, im, boxes) else: masks = im_detect_mask(model, im_scale, boxes) timers['im_detect_mask'].toc() timers['misc_mask'].tic() cls_segms = segm_results( cls_boxes, masks, boxes, im.shape[0], im.shape[1] ) timers['misc_mask'].toc() else: cls_segms = None if cfg.MODEL.KEYPOINTS_ON and boxes.shape[0] > 0: timers['im_detect_keypoints'].tic() if cfg.TEST.KPS_AUG.ENABLED: heatmaps = im_detect_keypoints_aug(model, im, boxes) else: heatmaps = im_detect_keypoints(model, im_scale, boxes) timers['im_detect_keypoints'].toc() timers['misc_keypoints'].tic() cls_keyps = keypoint_results(cls_boxes, heatmaps, boxes) timers['misc_keypoints'].toc() else: cls_keyps = None return cls_boxes, cls_segms, cls_keyps
def im_detect_all(model, im, box_proposals, timers=None, boxes_in=None): if timers is None: timers = defaultdict(Timer) #all_boxes = np.loadtxt(boxes_in).astype(np.float32) #valid_boxes = [] #for i in range(all_boxes.shape[0]): # if all_boxes[i,0] >= 0: # all_boxes[i,2] += all_boxes[i,0] # all_boxes[i,3] += all_boxes[i,1] # valid_boxes.append(all_boxes[i,:]) #box_proposals = np.array(valid_boxes) #if boxes_in is None: if True: # Handle RetinaNet testing separately for now if cfg.RETINANET.RETINANET_ON: cls_boxes = test_retinanet.im_detect_bbox(model, im, timers) return cls_boxes, None, None timers['im_detect_bbox'].tic() if cfg.TEST.BBOX_AUG.ENABLED: scores, boxes, im_scale = im_detect_bbox_aug(model, im, box_proposals) else: scores, boxes, im_scale = im_detect_bbox( model, im, cfg.TEST.SCALE, cfg.TEST.MAX_SIZE, boxes=box_proposals ) timers['im_detect_bbox'].toc() # score and boxes are from the whole image after score thresholding and nms # (they are not separated by class) # cls_boxes boxes and scores are separated by class and in the format used # for evaluating results timers['misc_bbox'].tic() scores, boxes, cls_boxes = box_results_with_nms_and_limit(scores, boxes) timers['misc_bbox'].toc() if boxes_in is not None: timers['im_detect_bbox'].tic() all_boxes = np.loadtxt(boxes_in).astype(np.float32) timers['im_detect_bbox'].toc() timers['misc_bbox'].tic() valid_boxes = [] if len(all_boxes.shape) == 1: all_boxes = all_boxes.reshape([1, all_boxes.shape[0]]) for i in range(all_boxes.shape[0]): if all_boxes[i,0] >= 0: all_boxes[i,2] += all_boxes[i,0] all_boxes[i,3] += all_boxes[i,1] valid_boxes.append(all_boxes[i,:]) boxes = np.array(valid_boxes) if boxes.shape[0] == 0: return None, None, None, None cls_boxes = np.zeros([boxes.shape[0], 5]).astype(boxes.dtype) cls_boxes[:,0:4] = boxes cls_boxes[:,4] = 1.0 cls_boxes = [[], cls_boxes] scores = np.ones([boxes.shape[0]]).astype(boxes.dtype) im_scale = min(cfg.TEST.MAX_SIZE / float(max(im.shape[0], im.shape[1])), \ cfg.TEST.SCALE / float(min(im.shape[0], im.shape[1]))) timers['misc_bbox'].toc() if cfg.MODEL.MASK_ON and boxes.shape[0] > 0: timers['im_detect_mask'].tic() if cfg.TEST.MASK_AUG.ENABLED: masks = im_detect_mask_aug(model, im, boxes) else: masks = im_detect_mask(model, im_scale, boxes) timers['im_detect_mask'].toc() timers['misc_mask'].tic() cls_segms = segm_results( cls_boxes, masks, boxes, im.shape[0], im.shape[1] ) timers['misc_mask'].toc() else: cls_segms = None if cfg.MODEL.KEYPOINTS_ON and boxes.shape[0] > 0: timers['im_detect_keypoints'].tic() if cfg.TEST.KPS_AUG.ENABLED: heatmaps = im_detect_keypoints_aug(model, im, boxes) else: heatmaps = im_detect_keypoints(model, im_scale, boxes) timers['im_detect_keypoints'].toc() timers['misc_keypoints'].tic() cls_keyps = keypoint_results(cls_boxes, heatmaps, boxes) timers['misc_keypoints'].toc() else: cls_keyps = None if cfg.MODEL.BODY_UV_ON and boxes.shape[0] > 0: timers['im_detect_body_uv'].tic() cls_bodys = im_detect_body_uv(model, im_scale, boxes) timers['im_detect_body_uv'].toc() else: cls_bodys = None return cls_boxes, cls_segms, cls_keyps, cls_bodys
def im_detect_all(model, im, box_proposals, timers=None, return_feats=False): if timers is None: timers = defaultdict(Timer) # Handle RetinaNet testing separately for now if cfg.RETINANET.RETINANET_ON: cls_boxes = test_retinanet.im_detect_bbox(model, im, timers) return cls_boxes, None, None timers['im_detect_bbox'].tic() if cfg.TEST.BBOX_AUG.ENABLED: scores, boxes, im_scale = im_detect_bbox_aug(model, im, box_proposals) else: scores, boxes, im_scale, feats = im_detect_bbox(model, im, cfg.TEST.SCALE, cfg.TEST.MAX_SIZE, boxes=box_proposals, get_feats=return_feats) timers['im_detect_bbox'].toc() # Now scores contains all rpn_rois, together with the rpn boxes, and 'boxes' are the rpn_boxes adjusted by the final regression outputs. # score and boxes are from the whole image after score thresholding and nms # (they are not separated by class) # cls_boxes boxes and scores are separated by class and in the format used # for evaluating results timers['misc_bbox'].tic() scores, boxes, cls_boxes, sum_softmax, topk_feats = box_results_with_nms_and_limit( scores, boxes, feats=feats) timers['misc_bbox'].toc() # Now cls_boxes contains the nms_dets with all final boxes and (per class NMS pruned) softmax outputs. if cfg.MODEL.MASK_ON and boxes.shape[0] > 0: timers['im_detect_mask'].tic() if cfg.TEST.MASK_AUG.ENABLED: masks = im_detect_mask_aug(model, im, boxes) else: masks = im_detect_mask(model, im_scale, boxes) timers['im_detect_mask'].toc() timers['misc_mask'].tic() cls_segms = segm_results(cls_boxes, masks, boxes, im.shape[0], im.shape[1]) timers['misc_mask'].toc() else: cls_segms = None if cfg.MODEL.KEYPOINTS_ON and boxes.shape[0] > 0: timers['im_detect_keypoints'].tic() if cfg.TEST.KPS_AUG.ENABLED: heatmaps = im_detect_keypoints_aug(model, im, boxes) else: heatmaps = im_detect_keypoints(model, im_scale, boxes) timers['im_detect_keypoints'].toc() timers['misc_keypoints'].tic() cls_keyps = keypoint_results(cls_boxes, heatmaps, boxes) timers['misc_keypoints'].toc() else: cls_keyps = None return cls_boxes, cls_segms, cls_keyps, sum_softmax, topk_feats
def multi_im_detect_all(model, im_list, box_proposals_list, timers=None, tracking=True): """Multi-image inference (e.g. image pair object associations) """ if timers is None: timers = defaultdict(Timer) boxes_list = [] boxes_raw_list = [] im_scale_list = [] cls_boxes_list = [] cls_segms_list = [] cls_keyps_list = [] fpn_res_sum_list = [{}, {}] fpn_res_blob_names = ['5_2', '4_5', '3_3', '2_2'] fpn_res_blob_names = [ 'fpn_res{}_sum'.format(name) for name in fpn_res_blob_names ] # Handle RetinaNet testing separately for now if cfg.RETINANET.RETINANET_ON: for im in im_list: cls_boxes = test_retinanet.im_detect_bbox(model, im, timers) cls_boxes_list.append(cls_boxes) empty = [None] * len(im_list) return cls_boxes_list, empty, empty, empty for i, im in enumerate(im_list): box_proposals = box_proposals_list[i] timers['im_detect_bbox'].tic() if cfg.TEST.BBOX_AUG.ENABLED: scores, boxes, im_scale = im_detect_bbox_aug( model, im, box_proposals) else: scores, boxes, im_scale = im_detect_bbox(model, im, cfg.TEST.SCALE, cfg.TEST.MAX_SIZE, boxes=box_proposals) for blob_name in fpn_res_blob_names: fpn_res_sum_list[i][blob_name] = workspace.FetchBlob( core.ScopedName(blob_name)) timers['im_detect_bbox'].toc() im_scale_list.append(im_scale) boxes_raw_list.append(boxes) # score and boxes are from the whole image after score thresholding and nms # (they are not separated by class) # cls_boxes boxes and scores are separated by class and in the format used # for evaluating results timers['misc_bbox'].tic() scores, boxes, cls_boxes = box_results_with_nms_and_limit( scores, boxes) timers['misc_bbox'].toc() boxes_list.append(boxes) cls_boxes_list.append(cls_boxes) if cfg.MODEL.MASK_ON and boxes.shape[0] > 0: timers['im_detect_mask'].tic() if cfg.TEST.MASK_AUG.ENABLED: masks = im_detect_mask_aug(model, im, boxes) else: masks = im_detect_mask(model, im_scale, boxes) timers['im_detect_mask'].toc() timers['misc_mask'].tic() cls_segms = segm_results(cls_boxes, masks, boxes, im.shape[0], im.shape[1]) timers['misc_mask'].toc() cls_segms_list.append(cls_segms) else: cls_segms_list.append(None) if cfg.MODEL.KEYPOINTS_ON and boxes.shape[0] > 0: timers['im_detect_keypoints'].tic() if cfg.TEST.KPS_AUG.ENABLED: heatmaps = im_detect_keypoints_aug(model, im, boxes) else: heatmaps = im_detect_keypoints(model, im_scale, boxes) timers['im_detect_keypoints'].toc() timers['misc_keypoints'].tic() cls_keyps = keypoint_results(cls_boxes, heatmaps, boxes) timers['misc_keypoints'].toc() cls_keyps_list.append(cls_keyps) else: cls_keyps_list.append(None) if cfg.MODEL.TRACKING_ON and boxes.shape[0] > 0 and tracking: timers['im_detect_track'].tic() track = im_detect_track(model, im_scale_list, boxes_list, fpn_res_sum_list) timers['im_detect_track'].toc() timers['misc_track'].tic() track_mat = track_results(cls_boxes_list, track) timers['misc_track'].toc() else: track_mat = None return cls_boxes_list, cls_segms_list, cls_keyps_list, track_mat, [ im_scale_list, boxes_list, fpn_res_sum_list ]
def im_detect_all_seq(model, im, box_proposals, prev, timers=None, tracking=True): """Sequential inference based on information from a previous frame """ if timers is None: timers = defaultdict(Timer) cls_boxes_prev, fpn_res_sum_prev, boxes_prev, im_scale_prev = prev fpn_res_sum = {} fpn_res_blob_names = ['5_2', '4_5', '3_3', '2_2'] fpn_res_blob_names = [ 'fpn_res{}_sum'.format(name) for name in fpn_res_blob_names ] # Handle RetinaNet testing separately for now if cfg.RETINANET.RETINANET_ON: for im in im: cls_boxes = test_retinanet.im_detect_bbox(model, im, timers) return cls_boxes, None, None, None timers['im_detect_bbox'].tic() if cfg.TEST.BBOX_AUG.ENABLED: scores, boxes, im_scale = im_detect_bbox_aug(model, im, box_proposals) else: scores, boxes, im_scale = im_detect_bbox(model, im, cfg.TEST.SCALE, cfg.TEST.MAX_SIZE, boxes=box_proposals) for blob_name in fpn_res_blob_names: fpn_res_sum[blob_name] = workspace.FetchBlob( core.ScopedName(blob_name)) timers['im_detect_bbox'].toc() # score and boxes are from the whole image after score thresholding and nms # (they are not separated by class) # cls_boxes boxes and scores are separated by class and in the format used # for evaluating results timers['misc_bbox'].tic() scores, boxes, cls_boxes = box_results_with_nms_and_limit(scores, boxes) timers['misc_bbox'].toc() if cfg.MODEL.MASK_ON and boxes.shape[0] > 0: timers['im_detect_mask'].tic() if cfg.TEST.MASK_AUG.ENABLED: masks = im_detect_mask_aug(model, im, boxes) else: masks = im_detect_mask(model, im_scale, boxes) timers['im_detect_mask'].toc() timers['misc_mask'].tic() cls_segms = segm_results(cls_boxes, masks, boxes, im.shape[0], im.shape[1]) timers['misc_mask'].toc() else: cls_segms = None if cfg.MODEL.KEYPOINTS_ON and boxes.shape[0] > 0: timers['im_detect_keypoints'].tic() if cfg.TEST.KPS_AUG.ENABLED: heatmaps = im_detect_keypoints_aug(model, im, boxes) else: heatmaps = im_detect_keypoints(model, im_scale, boxes) timers['im_detect_keypoints'].toc() timers['misc_keypoints'].tic() cls_keyps = keypoint_results(cls_boxes, heatmaps, boxes) timers['misc_keypoints'].toc() else: cls_keyps = None if cfg.MODEL.TRACKING_ON and tracking: if len(boxes_prev) and len(boxes): timers['im_detect_track'].tic() track = im_detect_track(model, [im_scale_prev, im_scale], [boxes_prev, boxes], [fpn_res_sum_prev, fpn_res_sum]) timers['im_detect_track'].toc() timers['misc_track'].tic() track_mat = track_results([cls_boxes_prev, cls_boxes], track) timers['misc_track'].toc() else: track_mat = np.empty((len(boxes_prev), len(boxes))) else: track_mat = None return cls_boxes, cls_segms, cls_keyps, track_mat, [ im_scale, boxes, fpn_res_sum ]