图片处理也没有问题,甚至可以跑一部分过程,但训练到一半就报错,求大佬们看看是什么问题
报错
InvalidArgumentError: Got 24 frames, but animated gifs can only be decoded by tf.image.decode_gif or tf.image.decode_image
[[Node: DecodeJpeg = DecodeJpeg[acceptable_fraction=0.5, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](ReadFile)]]
图像处理代码块
def get_batch(image,label,image_W,image_H,batch_size,capacity):
image = tf.cast(image,tf.string)
label = tf.cast(label,tf.int32)
#tf.cast()用来做类型转换
input_queue = tf.train.slice_input_producer([image,label])
#加入队列
label = input_queue[1]
image_contents = tf.read_file(input_queue[0])
image = tf.image.decode_jpeg(image_contents,channels=3,try_recover_truncated = True,acceptable_fraction=0.5)
#jpeg或者jpg格式都用decode_jpeg函数,其他格式可以去查看官方文档
image = tf.image.resize_image_with_crop_or_pad(image,image_W,image_H)
#resize
image = tf.image.per_image_standardization(image)
#对resize后的图片进行标准化处理
image_batch,label_batch = tf.train.batch([image,label],batch_size = batch_size,num_threads=16,capacity = capacity)
label_batch = tf.reshape(label_batch,[batch_size])
image_batch = tf.cast(image_batch,tf.float32)
return image_batch,label_batch
#获取两个batch,两个batch即为传入神经网络的数据
编译报错截图
可以看到还是跑了一点点的