(img, im_shape, pixel_means=PIXEL_MEANS)
return Image.fromarray(img)
Given an image from the dataloader, undoes the transformations.
Given an image from the dataloader, undoes the transformations.
Given an image from the dataloader undoes the transformations .
def prepare_image(img, im_shape, pixel_means=PIXEL_MEANS):
    """
    Given an image from the dataloader, undoes the transformations.
    """
    img = img.reshape((3, im_shape[0], im_shape[1]))
    # transpose from CHW to H W C
    img = img.transpose(1, 2, 0) + pixel_means
    # reorder color channel
    img = img[:, :, ::-1]

    img = img.astype('uint8')

    return Image.fromarray(img)
def prepare_image ( img , im_shape , pixel_means = PIXEL_MEANS ) : img = img . reshape ( ( 3 , im_shape [ 0 ] , im_shape [ 1 ] ) ) # transpose from CHW to H W C img = img . transpose ( 1 , 2 , 0 ) + pixel_means # reorder color channel img = img [ : , : , : : - 1 ] img = img . astype ( 'uint8' ) return Image . fromarray ( img )