utils.py 文件源码

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

项目:nn-compression 作者: anithapk 项目源码 文件源码
def load_image(path):
    # load image
    nImgs = len(path)
    rImg = np.zeros([nImgs,224,224,3])
    for i in range(nImgs):
        img = cv2.imread(path[i])
        img = img / 255.0
        assert (0 <= img).all() and (img <= 1.0).all()
        # print "Original Image Shape: ", img.shape
        # we crop image from center
        short_edge = min(img.shape[:2])
        yy = int((img.shape[0] - short_edge) / 2)
        xx = int((img.shape[1] - short_edge) / 2)
        crop_img = img[yy: yy + short_edge, xx: xx + short_edge]
        # resize to 224, 224
        resized_img = cv2.resize(img,(224,224),interpolation = cv2.INTER_CUBIC) #skimage.transform.resize(crop_img, (224, 224))
        rImg[i] = resized_img
    return rImg

# returns the top1 string
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号