def get_minibatch(roidb, num_classes):
    'Given a roidb, construct a minibatch sampled from it.'
    num_images = len(roidb)
    random_scale_inds = npr.randint(0, high=len(cfg.TRAIN.SCALES), size=num_images)
    assert ((cfg.TRAIN.BATCH_SIZE % num_images) == 0), 'num_images ({}) must divide BATCH_SIZE ({})'.format(num_images, cfg.TRAIN.BATCH_SIZE)
    (im_blob, im_scales) = _get_image_blob(roidb, random_scale_inds)
    blobs = {'data': im_blob}
    assert (len(im_scales) == 1), 'Single batch only'
    assert (len(roidb) == 1), 'Single batch only'
    sep = '/'
    clp_file_format = '.npy'
    clp_file_store = 'CloudPoints'
    img_path = roidb[0]['image']
    img_path_arr = img_path.split(sep)
    prefix = img_path_arr[:(- 2)]
    file_name = (img_path_arr[(- 1)].split('.')[0] + clp_file_format)
    clp_path = os.path.join(sep.join(prefix), clp_file_store, file_name)
    valid_points = np.load(clp_path)
    width_ori = roidb[0]['height']
    height_ori = roidb[0]['width']
    clp_ori = np.zeros([width_ori, height_ori], dtype=np.float32)
    clp_ori[tuple((valid_points.T[1, :], valid_points.T[0, :]))] = 1
    clp_reshape = np.empty([width_ori, height_ori, 3], dtype=np.float32)
    for i in range(3):
        clp_reshape[0:width_ori, 0:height_ori, i] = clp_ori
    clp_res = cv2.resize(clp_reshape, None, None, fx=im_scales[0], fy=im_scales[0], interpolation=cv2.INTER_LINEAR)
    clp_res = clp_res[:, :, 0]
    clp_res[(clp_res > 0)] = 1
    width = clp_res.shape[0]
    height = clp_res.shape[1]
    clp_res = clp_res.reshape([1, width, height, 1])
    blobs['clp_info'] = clp_res
    if cfg.TRAIN.USE_ALL_GT:
        gt_inds = np.where((roidb[0]['gt_classes'] != 0))[0]
    else:
        gt_inds = np.where((roidb[0]['gt_classes'] != (0 & np.all((roidb[0]['gt_overlaps'].toarray() > (- 1.0)), axis=1))))[0]
    gt_boxes = np.empty((len(gt_inds), 5), dtype=np.float32)
    gt_boxes[:, 0:4] = (roidb[0]['boxes'][gt_inds, :] * im_scales[0])
    gt_boxes[:, 4] = roidb[0]['gt_classes'][gt_inds]
    blobs['gt_boxes'] = gt_boxes
    blobs['im_info'] = np.array([im_blob.shape[1], im_blob.shape[2], im_scales[0]], dtype=np.float32)
    return blobs
Given a roidb, construct a minibatch sampled from it.
def get_minibatch(roidb, num_classes):
    
    num_images = len(roidb)
    random_scale_inds = npr.randint(0, high=len(cfg.TRAIN.SCALES), size=num_images)
    assert ((cfg.TRAIN.BATCH_SIZE % num_images) == 0), 'num_images ({}) must divide BATCH_SIZE ({})'.format(num_images, cfg.TRAIN.BATCH_SIZE)
    (im_blob, im_scales) = _get_image_blob(roidb, random_scale_inds)
    blobs = {'data': im_blob}
    assert (len(im_scales) == 1), 'Single batch only'
    assert (len(roidb) == 1), 'Single batch only'
    sep = '/'
    clp_file_format = '.npy'
    clp_file_store = 'CloudPoints'
    img_path = roidb[0]['image']
    img_path_arr = img_path.split(sep)
    prefix = img_path_arr[:(- 2)]
    file_name = (img_path_arr[(- 1)].split('.')[0] + clp_file_format)
    clp_path = os.path.join(sep.join(prefix), clp_file_store, file_name)
    valid_points = np.load(clp_path)
    width_ori = roidb[0]['height']
    height_ori = roidb[0]['width']
    clp_ori = np.zeros([width_ori, height_ori], dtype=np.float32)
    clp_ori[tuple((valid_points.T[1, :], valid_points.T[0, :]))] = 1
    clp_reshape = np.empty([width_ori, height_ori, 3], dtype=np.float32)
    for i in range(3):
        clp_reshape[0:width_ori, 0:height_ori, i] = clp_ori
    clp_res = cv2.resize(clp_reshape, None, None, fx=im_scales[0], fy=im_scales[0], interpolation=cv2.INTER_LINEAR)
    clp_res = clp_res[:, :, 0]
    clp_res[(clp_res > 0)] = 1
    width = clp_res.shape[0]
    height = clp_res.shape[1]
    clp_res = clp_res.reshape([1, width, height, 1])
    blobs['clp_info'] = clp_res
    if cfg.TRAIN.USE_ALL_GT:
        gt_inds = np.where((roidb[0]['gt_classes'] != 0))[0]
    else:
        gt_inds = np.where((roidb[0]['gt_classes'] != (0 & np.all((roidb[0]['gt_overlaps'].toarray() > (- 1.0)), axis=1))))[0]
    gt_boxes = np.empty((len(gt_inds), 5), dtype=np.float32)
    gt_boxes[:, 0:4] = (roidb[0]['boxes'][gt_inds, :] * im_scales[0])
    gt_boxes[:, 4] = roidb[0]['gt_classes'][gt_inds]
    blobs['gt_boxes'] = gt_boxes
    blobs['im_info'] = np.array([im_blob.shape[1], im_blob.shape[2], im_scales[0]], dtype=np.float32)
    return blobs