Exemplo n.º 1
0
def get_processed_image(img_crop):
    # Load image and convert from BGR to RGB
    im = np.asarray(img_crop)[:, :, ::-1]
    im = cv2.resize(im, (299, 299))
    im = inception_v4.preprocess_input(im)
    if K.image_data_format() == "channels_first":
        im = np.transpose(im, (2, 0, 1))
        im = im.reshape(-1, 3, 299, 299)
    else:
        im = im.reshape(-1, 299, 299, 3)
    return im
def get_processed_image(img_path):
    # Load image and convert from BGR to RGB
    im = cv2.imread(img_path)
    if im is None:
        return None
    im = np.asarray(im)[:, :, ::-1]
    im = central_crop(im, 0.875)
    im = cv2.resize(im, (299, 299))
    im = inception_v4.preprocess_input(im)
    if K.image_data_format() == "channels_first":
        im = np.transpose(im, (2, 0, 1))
    return im