2017-02-14 52 views
0

我目前正在运行的这一点:如何将URL中的图像加载到张量流中?

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

,我得到这个错误:

Unable to get element from the feed as bytes.

+0

你可以发布一个完整的可运行代码,gfile是什么意思? –

+0

对不起,我想将img数据放入一个[bytesio](https://docs.python.org/3/library/io.html#binary-io),但我没有找到任何可用的api在张量流中。 –

回答

2

的解决方案是很简单......我所要做的就是调用read方法从响应的urlopen。下面的作品就像一个魅力:

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