tf.read_file
時ではなく、セッション実行時に実際に読み込まれます。
また、arrayとして取得したい場合はtf.image.decode_jpeg
が利用できます。
参考:TensorFlowのReaderクラスを使ってみる
Python
1import tensorflow as tf
2f = tf.read_file('lena.jpg')
3print(f) # Tensor("ReadFile:0", shape=(), dtype=string)
4img = tf.image.decode_jpeg(f, channels=3)
5print(img) # Tensor("DecodeJpeg:0", shape=(?, ?, 3), dtype=uint8)
6
7sess = tf.Session()
8sess.run(tf.global_variables_initializer())
9
10ret_f = sess.run(f)
11#print(ret_f)
12# b'\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00I\x00I\x00\x00\xff\xfe\x00-Handmade Softwarer~
13
14ret_img = sess.run(img)
15print(ret_img,ret_img.shape)
16# [[[225 138 128]
17# (略)
18# [187 73 83]]] (512, 512, 3)
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。