Detectron/detectron/roi_data/minibatch.py
def _get_image_blob(roidb):
    """Builds an input blob from the images in the roidb at the specified
    scales.
    """
    num_images = len(roidb)
    # Sample random scales to use for each image in this batch
    scale_inds = np.random.randint(
        0, high=len(cfg.TRAIN.SCALES), size=num_images
    )
    processed_ims = []
    im_scales = []
    Gauss_kernel = 0
    SigmaX = 0
    alpha = 1
    beta = 0
    for i in range(num_images):
        im = cv2.imread(roidb[i]['image'])
        if cfg.TRAIN.AUGUMENT:
            im_tmp  = cv2.imread(roidb[i]['image'])
            random_flag = random.randint(0, 1)
            #print(random_flag)
            if random_flag :
                Gauss_kernel = 7#np.random.randint(5, 7)
                SigmaX = 5.5#np.random.randint(0, 70) /10.0

                im = randomGaussian(im_tmp,Gauss_kernel,SigmaX)
                alpha = np.random.randint(0, 15) / 10.0
                beta = np.random.randint(0, 15)
                im = Contrast_and_Brightness(alpha, beta, im)
                #cv2.imwrite('test.jpg',im)
            else:
                im = im_tmp.copy()
        #print(random_flag,alpha,beta)
        assert im is not None, \
            'Failed to read image \'{}\''.format(roidb[i]['image'])
        if roidb[i]['flipped']:
            im = im[:, ::-1, :]
        target_size = cfg.TRAIN.SCALES[scale_inds[i]]
        im, im_scale = blob_utils.prep_im_for_blob(
            im, cfg.PIXEL_MEANS, target_size, cfg.TRAIN.MAX_SIZE
        )
        im_scales.append(im_scale)
        processed_ims.append(im)

    # Create a blob to hold the input images
    blob = blob_utils.im_list_to_blob(processed_ims)

    return blob, im_scales
Builds an input blob from the images in the roidb at the specified
    scales.
    
Builds an input blob from the images in the roidb at the specified
scales.
Builds an input blob from the images in the roidb at the specified scales .
def _get_image_blob(roidb):
    num_images = len(roidb)
    scale_inds = np.random.randint(
        0, high=len(cfg.TRAIN.SCALES), size=num_images
    )
    processed_ims = []
    im_scales = []
    Gauss_kernel = 0
    SigmaX = 0
    alpha = 1
    beta = 0
    for i in range(num_images):
        im = cv2.imread(roidb[i]['image'])
        if cfg.TRAIN.AUGUMENT:
            im_tmp  = cv2.imread(roidb[i]['image'])
            random_flag = random.randint(0, 1)
            if random_flag :
                Gauss_kernel = 7
                SigmaX = 5.5
                im = randomGaussian(im_tmp,Gauss_kernel,SigmaX)
                alpha = np.random.randint(0, 15) / 10.0
                beta = np.random.randint(0, 15)
                im = Contrast_and_Brightness(alpha, beta, im)
            else:
                im = im_tmp.copy()
        assert im is not None, \
            'Failed to read image \'{}\''.format(roidb[i]['image'])
        if roidb[i]['flipped']:
            im = im[:, ::-1, :]
        target_size = cfg.TRAIN.SCALES[scale_inds[i]]
        im, im_scale = blob_utils.prep_im_for_blob(
            im, cfg.PIXEL_MEANS, target_size, cfg.TRAIN.MAX_SIZE
        )
        im_scales.append(im_scale)
        processed_ims.append(im)
    blob = blob_utils.im_list_to_blob(processed_ims)
    return blob, im_scales
def _get_image_blob ( roidb ) : num_images = len ( roidb ) scale_inds = np . random . randint ( 0 , high = len ( cfg . TRAIN . SCALES ) , size = num_images ) processed_ims = [ ] im_scales = [ ] Gauss_kernel = 0 SigmaX = 0 alpha = 1 beta = 0 for i in range ( num_images ) : im = cv2 . imread ( roidb [ i ] [ 'image' ] ) if cfg . TRAIN . AUGUMENT : im_tmp = cv2 . imread ( roidb [ i ] [ 'image' ] ) random_flag = random . randint ( 0 , 1 ) if random_flag : Gauss_kernel = 7 SigmaX = 5.5 im = randomGaussian ( im_tmp , Gauss_kernel , SigmaX ) alpha = np . random . randint ( 0 , 15 ) / 10.0 beta = np . random . randint ( 0 , 15 ) im = Contrast_and_Brightness ( alpha , beta , im ) else : im = im_tmp . copy ( ) assert im is not None , 'Failed to read image \'{}\'' . format ( roidb [ i ] [ 'image' ] ) if roidb [ i ] [ 'flipped' ] : im = im [ : , : : - 1 , : ] target_size = cfg . TRAIN . SCALES [ scale_inds [ i ] ] im , im_scale = blob_utils . prep_im_for_blob ( im , cfg . PIXEL_MEANS , target_size , cfg . TRAIN . MAX_SIZE ) im_scales . append ( im_scale ) processed_ims . append ( im ) blob = blob_utils . im_list_to_blob ( processed_ims ) return blob , im_scales
Builds an input blob from the images in the roidb at the specified
scales.
Builds an input blob from the images in the roidb at the specified scales .
"""Builds an input blob from the images in the roidb at the specified
    scales.
    """ # Sample random scales to use for each image in this batch #print(random_flag) #np.random.randint(5, 7) #np.random.randint(0, 70) /10.0 #cv2.imwrite('test.jpg',im) #print(random_flag,alpha,beta) # Create a blob to hold the input images
roidb