0
我管理使用下面的代码来显示图像:Tensorflow v0.12图像不displying调整后
import os
import tensorflow as tf
from tensorflow.python.framework import ops
from tensorflow.python.framework import dtypes
import numpy as np
import glob
import fnmatch
import matplotlib.pyplot as plt
from PIL import Image
def test1(path):
filename_queue = tf.train.string_input_producer(tf.train.match_filenames_once(path))
image_reader = tf.WholeFileReader()
label, image_file = image_reader.read(filename_queue)
image = tf.image.decode_jpeg(image_file,3)
print(image)
image = tf.image.resize_images(image, [224 , 224])
print(image)
with tf.Session() as sess:
tf.global_variables_initializer().run()
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
for i in range(1):
img = image.eval()
Image.fromarray(np.asarray(img)).show()
coord.request_stop()
coord.join(threads)
sess.close()
if __name__== "__main__":
test1("./data/test1/1099.jpg")
给它:
import os
import tensorflow as tf
from tensorflow.python.framework import ops
from tensorflow.python.framework import dtypes
import numpy as np
import glob
import fnmatch
import matplotlib.pyplot as plt
from PIL import Image
def test1(path):
filename_queue = tf.train.string_input_producer(tf.train.match_filenames_once(path))
image_reader = tf.WholeFileReader()
label, image_file = image_reader.read(filename_queue)
image = tf.image.decode_jpeg(image_file,3)
print(image)
with tf.Session() as sess:
tf.global_variables_initializer().run()
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
for i in range(1):
img = image.eval()
Image.fromarray(np.asarray(img)).show()
coord.request_stop()
coord.join(threads)
sess.close()
if __name__== "__main__":
test1("./data/test1/1099.jpg")
然而
当我使用下面的代码调整图像大小以下错误信息:
raise TypeError(“无法处理此数据类型”) TypeError:无法处理此数据类型
感谢
那么什么是影像D型?打印(image.dtype)或打印(tf.DType(图片)) – Steven
@Steven感谢您回复我的问题。 print(image.dtype)产生张量(“DecodeJpeg:0”,shape =(?,?3),dtype = uint8),同时print(tf.DType(image))产生TypeError :int()参数必须是一个字符串或数字,而不是'张量' –
dragon
很高兴你把它修好了。您应该接受您的答案,以便您可以结束该问题。 – Steven