1

I'm currently running this:

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

and I get this error:

Unable to get element from the feed as bytes.

JJJ
  • 2,889
  • 3
  • 25
  • 43
  • Can you post a full runable code, What is the meaning of the `gfile`? – bwangel Feb 14 '17 at 07:33
  • sorry, I want to place the img data into a [bytesio](https://docs.python.org/3/library/io.html#binary-i-o), but i didn't find any api can be used in tensorflow. – bwangel Feb 15 '17 at 05:58

2 Answers2

3

The solution was quite simple... All I had to do was call the read method on response from urlopen. The following works like a charm:

image = urllib.urlopen(imgUrl)
pool3_features = sess.run(pool3,{'incept/DecodeJpeg/contents:0': image.read()})
JJJ
  • 2,889
  • 3
  • 25
  • 43
-1

Just use a method to load it into NumPy and then load that into TensorFlow. This is likely more reliable, more flexible.

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

aselle
  • 639
  • 3
  • 5