(bounding_boxes, img, size=24)
return img_boxes
Cut out boxes from the image.

    Arguments:
        bounding_boxes: a float numpy array of shape [n, 5].
        img: an instance of PIL.Image.
        size: an integer, size of cutouts.

    Returns:
        a float numpy array of shape [n, 3, size, size].
Cut out boxes from the image.
Cut out boxes from the image .
def get_image_boxes(bounding_boxes, img, size=24):
    """Cut out boxes from the image.

    Arguments:
        bounding_boxes: a float numpy array of shape [n, 5].
        img: an instance of PIL.Image.
        size: an integer, size of cutouts.

    Returns:
        a float numpy array of shape [n, 3, size, size].
    """

    num_boxes = len(bounding_boxes)
    width, height = img.size

    [dy, edy, dx, edx, y, ey, x, ex, w, h] = correct_bboxes(bounding_boxes, width, height)
    img_boxes = np.zeros((num_boxes, 3, size, size), 'float32')

    for i in range(num_boxes):
        img_box = np.zeros((h[i], w[i], 3), 'uint8')

        img_array = np.asarray(img, 'uint8')
        img_box[dy[i]:(edy[i] + 1), dx[i]:(edx[i] + 1), :] =\
            img_array[y[i]:(ey[i] + 1), x[i]:(ex[i] + 1), :]

        # resize
        img_box = Image.fromarray(img_box)
        img_box = img_box.resize((size, size), Image.BILINEAR)
        img_box = np.asarray(img_box, 'float32')

        img_boxes[i, :, :, :] = _preprocess(img_box)

    return img_boxes
def get_image_boxes ( bounding_boxes , img , size = 24 ) : num_boxes = len ( bounding_boxes ) width , height = img . size [ dy , edy , dx , edx , y , ey , x , ex , w , h ] = correct_bboxes ( bounding_boxes , width , height ) img_boxes = np . zeros ( ( num_boxes , 3 , size , size ) , 'float32' ) for i in range ( num_boxes ) : img_box = np . zeros ( ( h [ i ] , w [ i ] , 3 ) , 'uint8' ) img_array = np . asarray ( img , 'uint8' ) img_box [ dy [ i ] : ( edy [ i ] + 1 ) , dx [ i ] : ( edx [ i ] + 1 ) , : ] = img_array [ y [ i ] : ( ey [ i ] + 1 ) , x [ i ] : ( ex [ i ] + 1 ) , : ] # resize img_box = Image . fromarray ( img_box ) img_box = img_box . resize ( ( size , size ) , Image . BILINEAR ) img_box = np . asarray ( img_box , 'float32' ) img_boxes [ i , : , : , : ] = _preprocess ( img_box ) return img_boxes