【发布时间】:2018-12-19 14:39:12
【问题描述】:
对于从网络摄像头读取的 640x480x3 图像,为 TensorFlow 准备它的瓶颈是这个 reshape 命令:
def load_image_into_numpy_array(image):
(im_width, im_height) = image.size
return np.array(image.getdata()).reshape((im_height, im_width, 3)).astype(np.uint8)
为什么这需要这么长时间,有什么办法可以加快速度?
【问题讨论】:
-
你确定
image.getdata()不是问题吗?你在这里使用了探查器,还是只打印了几张?reshape对您的数据不做任何事情(它只是元数据,它不会改变内存)。转换为np.uint8也应该很快。 -
我认为你是对的,getdata() 命令是慢的部分
标签: python numpy tensorflow