htmls = "http://www.google.com"
tree = [0]*255
trees = [0]*255
for x in range(255):
page = requests.get(htmls)
tree[x] = html.fromstring(page.content)
png = imgkit.from_url(htmls, 'out.png')
trees[x] = tf.io.decode_png(
'out.png'
)
它继续想出
tensorflow.python.framework.errors_impl.InvalidArgumentError: Expected image (JPEG, PNG, or GIF), got unknown format starting with 'out.png' [Op:DecodePng]
虽然 png 从这个命令之外看起来很好
请您参考如下方法:
根据docs第一个参数应该是字符串类型的张量。
with tf.Session() as session:
content = tf.placeholder(tf.string)
tensor = tf.image.decode_image(contents=content) # your using tf.io.decode_png
trees[x] = (session.run(tensor, {content: 'out.png'}))
读一个img好像很费功夫,我觉得opencv会更好
import cv2
trees[x] = cv2.imread('out.png')
