コード例 #1
0
    def _imagePreprocess(self, blob, fix_size=True):
        keep = np.arange(blob['gt_boxes'].shape[0])
        if self.augmentation:
            if self.augImageOnly is not None:
                blob['data'] = self.augImageOnly(blob['data'])
            if self.augObjdet is not None:                blob['data'], blob['gt_boxes'], _, keep, _ = \
self.augObjdet(image=blob['data'], boxes=blob['gt_boxes'], boxes_keep=keep)

        # choose one predefined size, TODO: support multi-instance batch
        random_scale_ind = np.random.randint(0, high=len(cfg.SCALES))
        blob['data'], im_scale = prep_im_for_blob(blob['data'],
                                                  cfg.SCALES[random_scale_ind],
                                                  cfg.TRAIN.COMMON.MAX_SIZE,
                                                  fix_size)
        # modify bounding boxes according to resize parameters
        blob['im_info'][:2] = (blob['data'].shape[0], blob['data'].shape[1])
        blob['im_info'][2:4] = (im_scale['y'], im_scale['x'])
        blob['gt_boxes'][:, :-1][:, 0::2] *= im_scale['x']
        blob['gt_boxes'][:, :-1][:, 1::2] *= im_scale['y']
        blob['data'] = image_normalize(blob['data'],
                                       mean=self.pixel_means,
                                       std=self.pixel_stds)
        blob['node_inds'] = blob['node_inds'][keep]
        blob['parent_lists'] = [
            blob['parent_lists'][p_ind] for p_ind in list(keep)
        ]
        blob['child_lists'] = [
            blob['child_lists'][c_ind] for c_ind in list(keep)
        ]
        return blob
コード例 #2
0
    def _imagePreprocess(self, blob, fix_size=False):
        assert not fix_size, "When grasp labels are included, the input image can not be fixed-size."
        keep_b = np.arange(blob['gt_boxes'].shape[0])
        keep_g = np.arange(blob['gt_grasps'].shape[0])
        if self.augmentation:
            blob['data'] = self.augImageOnly(blob['data'])
            blob['data'], blob['gt_boxes'], blob['gt_grasps'], keep_b, keep_g = \
                self.augObjdet(image=blob['data'], boxes=blob['gt_boxes'], grasps=blob['gt_grasps'],
                                boxes_keep=keep_b, grasps_keep=keep_g)

        # choose one predefined size, TODO: support multi-instance batch
        random_scale_ind = np.random.randint(0, high=len(cfg.SCALES))
        blob['data'], im_scale = prep_im_for_blob(blob['data'],
                                                  cfg.SCALES[random_scale_ind],
                                                  cfg.TRAIN.COMMON.MAX_SIZE,
                                                  fix_size)
        blob['im_info'][:2] = (blob['data'].shape[0], blob['data'].shape[1])
        blob['im_info'][2:4] = (im_scale['y'], im_scale['x'])
        # modify bounding boxes according to resize parameters
        blob['gt_boxes'][:, :-1][:, 0::2] *= im_scale['x']
        blob['gt_boxes'][:, :-1][:, 1::2] *= im_scale['y']
        blob['gt_grasps'][:, 0::2] *= im_scale['x']
        blob['gt_grasps'][:, 1::2] *= im_scale['y']
        blob['gt_grasp_inds'] = blob['gt_grasp_inds'][keep_g]
        blob['data'] = image_normalize(blob['data'],
                                       mean=self.pixel_means,
                                       std=self.pixel_stds)
        blob['node_inds'] = blob['node_inds'][keep_b]
        blob['parent_lists'] = [
            blob['parent_lists'][p_ind] for p_ind in list(keep_b)
        ]
        blob['child_lists'] = [
            blob['child_lists'][c_ind] for c_ind in list(keep_b)
        ]
        return blob
 def _imagePreprocess(self, blob, fix_size = True):
     keep = np.arange(blob['gt_grasps'].shape[0])
     if self.augmentation:
         blob['data'] = self.augImageOnly(blob['data'])
         blob['data'], _, blob['gt_grasps'], _, _ = self.augmGraspdet(image=blob['data'], grasps=blob['gt_grasps'], grasps_keep=keep)
     # choose one predefined size, TODO: support multi-instance batch
     random_scale_ind = np.random.randint(0, high=len(cfg.SCALES))
     blob['data'], im_scale = prep_im_for_blob(blob['data'], cfg.SCALES[random_scale_ind], cfg.TRAIN.COMMON.MAX_SIZE, fix_size)
     blob['im_info'][:2] = (blob['data'].shape[0], blob['data'].shape[1])
     blob['im_info'][2:4] = (im_scale['y'], im_scale['x'])
     blob['gt_grasps'][:, 0::2] *= im_scale['x']
     blob['gt_grasps'][:, 1::2] *= im_scale['y']
     blob['data'] = image_normalize(blob['data'], mean=cfg.PIXEL_MEANS, std=cfg.PIXEL_STDS)
     return blob