2017-04-13 7 views
0

後の画像のコードを表示する方法私はTFデコード画像は、私がしようとしてどのように見しようとしているtf.decode_image

import tensorflow as tf 
image1 = tf.image.decode_png('/usr/src/pycharm-2017.1/bin/pycharm.png') 
print(image1.shape) 
with tf.Session() as sess: 
    img = sess.run(image1) 
    print(img.shape, img) 

が、それは誤りも

InvalidArgumentError (see above for traceback): Invalid PNG header, data size 39 
[[Node: DecodePng = DecodePng[channels=0, dtype=DT_UINT8, _device="/job:localhost/replica:0/task:0/cpu:0"](DecodePng/contents)]] 

Iを上げますtf.image.decode_imageを試しましたが、うまくいきませんでした。 どうしたの?どうすれば修正できますか? をuをありがとう関数に渡す前にTensorflowとPNGを読み込むために必要があるので

答えて

0

tf.image.decode_pngは、文字列型のテンソルを受け付けます。

import tensorflow as tf 
image1 = tf.image.decode_png(tf.read_file('/usr/src/pycharm-2017.1/bin/pycharm.png')) 
print(image1.shape) 
with tf.Session() as sess: 
    img = sess.run(image1) 
    print(img.shape, img) 
+0

ああ、それは多くのことをworks.Thanks。 – Noodle

関連する問題