def deprocess(img4d):
img = img4d.copy()
if K.image_dim_ordering() == "th":
# (B, C, H, W)
img = img.reshape((img4d.shape[1], img4d.shape[2], img4d.shape[3]))
# (C, H, W) -> (H, W, C)
img = img.transpose((1, 2, 0))
else:
# (B, H, W, C)
img = img.reshape((img4d.shape[1], img4d.shape[2], img4d.shape[3]))
img[:, :, 0] += 103.939
img[:, :, 1] += 116.779
img[:, :, 2] += 123.68
# BGR -> RGB
img = img[:, :, ::-1]
img = np.clip(img, 0, 255).astype("uint8")
return img
########################### main ###########################
deep-dream.py 文件源码
python
阅读 44
收藏 0
点赞 0
评论 0
评论列表
文章目录