如何将图片从url加载到tensorflow?

2024-09-28 05:22:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在运行这个:

image = urllib.urlopen(imgUrl)
pool3_features = sess.run(pool3,{'incept/DecodeJpeg/contents:0': image})

我得到一个错误:

Unable to get element from the feed as bytes.


Tags: torunimageget错误contentsurlliburlopen
2条回答

只需使用一个方法将其加载到NumPy中,然后将其加载到TensorFlow中。这可能更可靠、更灵活。在

http://www.pyimagesearch.com/2015/03/02/convert-url-to-image-with-python-and-opencv/

解决办法很简单。。。我所要做的就是对来自urlopen的响应调用read方法。以下是一种魅力:

image = urllib.urlopen(imgUrl)
pool3_features = sess.run(pool3,{'incept/DecodeJpeg/contents:0': image.read()})

相关问题 更多 >

    热门问题