convnet_v2.py 文件源码

python
阅读 42 收藏 0 点赞 0 评论 0

项目:DogvsCat 作者: aysebilgegunduz 项目源码 文件源码
def read_image(file_path):
    img = cv2.imread(file_path, cv2.IMREAD_COLOR)  # cv2.IMREAD_GRAYSCALE
    if (img.shape[0] >= img.shape[1]):  # height is greater than width
        resizeto = (IMAGE_SIZE, int(round(IMAGE_SIZE * (float(img.shape[1]) / img.shape[0]))));
    else:
        resizeto = (int(round(IMAGE_SIZE * (float(img.shape[0]) / img.shape[1]))), IMAGE_SIZE);

    img2 = cv2.resize(img, (resizeto[1], resizeto[0]), interpolation=cv2.INTER_CUBIC)
    img3 = cv2.copyMakeBorder(img2, 0, IMAGE_SIZE - img2.shape[0], 0, IMAGE_SIZE - img2.shape[1], cv2.BORDER_CONSTANT,
                              0)

    return img3[:, :, ::-1]  # turn into rgb format
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号