def im_detect_bbox_hflip(model, im, target_scale, target_max_size, box_proposals=None): """Performs bbox detection on the horizontally flipped image. Function signature is the same as for im_detect_bbox. """ # Compute predictions on the flipped image im_hf = im[:, ::-1, :] im_width = im.shape[1] box_proposals_hf = box_utils.flip_boxes(box_proposals, im_width) scores_hf, boxes_hf, im_scale = im_detect_bbox(model, im_hf, target_scale, target_max_size, boxes=box_proposals_hf) if boxes_hf is not None: # Invert the detections computed on the flipped image boxes_inv = box_utils.flip_boxes(boxes_hf, im_width) else: boxes_inv = None return scores_hf, boxes_inv, im_scale
def im_detect_bbox_hflip(model, im, target_scale, target_max_size, box_proposals=None, region_box=None): """Performs bbox detection on the horizontally flipped image. Function signature is the same as for im_detect_bbox. """ # Compute predictions on the flipped image im_hf = im[:, ::-1, :] im_width = im.shape[1] if not cfg.MODEL.FASTER_RCNN: box_proposals_hf = box_utils.flip_boxes(box_proposals, im_width) else: box_proposals_hf = None scores_hf, boxes_hf, im_scale, _ = im_detect_bbox(model, im_hf, target_scale, target_max_size, boxes=box_proposals_hf, region_box=region_box) # Invert the detections computed on the flipped image boxes_inv = box_utils.flip_boxes(boxes_hf, im_width) return scores_hf, boxes_inv, im_scale
def __call__(self, to_transform): if to_transform['hflip']: to_transform['img'] = to_transform['img'][:, ::-1, :] im_width = to_transform['img'].shape[1] to_transform['proposals'] = box_utils.flip_boxes( to_transform['proposals'], im_width) return to_transform
def im_detect_bbox_hflip(model, im, box_proposals=None): """Performs bbox detection on the horizontally flipped image. Function signature is the same as for im_detect_bbox. """ # Compute predictions on the flipped image im_hf = im[:, ::-1, :] im_width = im.shape[1] if not cfg.MODEL.FASTER_RCNN: box_proposals_hf = box_utils.flip_boxes(box_proposals, im_width) else: box_proposals_hf = None scores_hf, boxes_hf, im_scales = im_detect_bbox( model, im_hf, box_proposals_hf ) # Invert the detections computed on the flipped image boxes_inv = box_utils.flip_boxes(boxes_hf, im_width) return scores_hf, boxes_inv, im_scales
def im_detect_bbox_hflip(model, im, box_proposals=None): """Performs bbox detection on the horizontally flipped image. Function signature is the same as for im_detect_bbox. """ # Compute predictions on the flipped image # im is a list now, to be compat with video case im_hf = [e[:, ::-1, :] for e in im] # Since all frames would be same shape, just take values from 1st im_width = im[0].shape[1] if not cfg.MODEL.FASTER_RCNN: box_proposals_hf = box_utils.flip_boxes(box_proposals, im_width) else: box_proposals_hf = None scores_hf, boxes_hf, im_scales = im_detect_bbox( model, im_hf, box_proposals_hf) # Invert the detections computed on the flipped image boxes_inv = box_utils.flip_boxes(boxes_hf, im_width) return scores_hf, boxes_inv, im_scales
def im_detect_bbox_hflip(model, im, target_scale, target_max_size, box_proposals=None): im_hf = im[:, ::-1, :] im_width = im.shape[1] if not cfg.MODEL.FASTER_RCNN: box_proposals_hf = box_utils.flip_boxes(box_proposals, im_width) else: box_proposals_hf = None scores_hf, boxes_hf, im_scale, _ = im_detect_bbox(model, im_hf, target_scale, target_max_size, boxes=box_proposals_hf) # Invert the detections computed on the flipped image boxes_inv = box_utils.flip_boxes(boxes_hf, im_width) return scores_hf, boxes_inv, im_scale
def im_detect_keypoints_hflip(model, im, boxes): """Computes keypoint predictions on the horizontally flipped image. Function signature is the same as for im_detect_keypoints_aug. """ # Compute keypoints for the flipped image im_hf = im[:, ::-1, :] boxes_hf = box_utils.flip_boxes(boxes, im.shape[1]) im_scales = im_conv_body_only(model, im_hf) heatmaps_hf = im_detect_keypoints(model, im_scales, boxes_hf) # Invert the predicted keypoints heatmaps_inv = keypoint_utils.flip_heatmaps(heatmaps_hf) return heatmaps_inv
def im_detect_mask_hflip(model, im, boxes): """Performs mask detection on the horizontally flipped image. Function signature is the same as for im_detect_mask_aug. """ # Compute the masks for the flipped image im_hf = im[:, ::-1, :] boxes_hf = box_utils.flip_boxes(boxes, im.shape[1]) im_scales = im_conv_body_only(model, im_hf) masks_hf = im_detect_mask(model, im_scales, boxes_hf) # Invert the predicted soft masks masks_inv = masks_hf[:, :, :, ::-1] return masks_inv
def im_detect_keypoints_hflip(model, im, target_scale, target_max_size, boxes): """Computes keypoint predictions on the horizontally flipped image. Function signature is the same as for im_detect_keypoints_aug. """ # Compute keypoints for the flipped image im_hf = im[:, ::-1, :] boxes_hf = box_utils.flip_boxes(boxes, im.shape[1]) im_scale = im_conv_body_only(model, im_hf, target_scale, target_max_size) heatmaps_hf = im_detect_keypoints(model, im_scale, boxes_hf) # Invert the predicted keypoints heatmaps_inv = keypoint_utils.flip_heatmaps(heatmaps_hf) return heatmaps_inv
def im_detect_mask_hflip(model, im, target_scale, target_max_size, boxes): """Performs mask detection on the horizontally flipped image. Function signature is the same as for im_detect_mask_aug. """ # Compute the masks for the flipped image im_hf = im[:, ::-1, :] boxes_hf = box_utils.flip_boxes(boxes, im.shape[1]) im_scale = im_conv_body_only(model, im_hf, target_scale, target_max_size) masks_hf = im_detect_mask(model, im_scale, boxes_hf) # Invert the predicted soft masks masks_inv = masks_hf[:, :, :, ::-1] return masks_inv
def im_detect_mask_hflip(model, im, target_scale, target_max_size, boxes): """Performs mask detection on the horizontally flipped image. Function signature is the same as for im_detect_mask_aug. """ # Compute the masks for the flipped image im_hf = im[:, ::-1, :] boxes_hf = box_utils.flip_boxes(boxes, im.shape[1]) # _, im_scale, _ = blob_utils.get_image_blob(im_hf, target_scale, target_max_size) blob_conv_hf, im_scale_hf = im_conv_body_only(model, im_hf, cfg.TEST.SCALE, cfg.TEST.MAX_SIZE) # im_scale = im_conv_body_only(model, im_hf, target_scale, target_max_size) masks_hf = im_detect_mask(model, im_scale_hf, boxes_hf, blob_conv_hf) # Invert the predicted soft masks masks_inv = masks_hf[:, :, :, ::-1] return masks_inv