示例#1
0
def prepare(filepath, mean_image, h, w):
    width = w
    height = h
    img_array = cv2.imread(filepath)  # read in the image
    img_array = imgproc.toUINT8(img_array)
    img_array = imgproc.process_image(img_array, (height, width))
    img_array = np.float32(img_array)
    new_array = cv2.resize(img_array, (width, height))  # resize image to match model's expected sizing
    res = new_array.reshape(-1, height, width, 3)

    res = res - mean_image
    return res  # return the image with shaping that TF wants.
示例#2
0
def prepare(filepath, mean_image, h, w):
    width = w
    height = h
    img_array = cv2.imread(
        filepath,
        cv2.IMREAD_UNCHANGED,
    )  # read in the image, convert to grayscale
    img_array = imgproc.toUINT8(img_array)
    img_array = imgproc.process_image(img_array, (height, width))
    #cv2.imshow("window", img_array)
    #cv2.waitKey()

    img_array = np.float32(img_array)

    new_array = cv2.resize(
        img_array,
        (width, height))  # resize image to match model's expected sizing

    res = new_array.reshape(-1, height, width, 3)

    res = res - mean_image
    return res  # return the image with shaping that TF wants.