不肯写代码的AC 2018-12-19 10:11 采纳率: 0%
浏览 1427

CNN训练图片分类报错-图像处理有问题

图片处理也没有问题,甚至可以跑一部分过程,但训练到一半就报错,求大佬们看看是什么问题
报错

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即为传入神经网络的数据

编译报错截图

图片说明

可以看到还是跑了一点点的

  • 写回答

1条回答 默认 最新

  • yzhhhhhhhhhhhhhh 2021-12-29 14:39
    关注

    我也遇到了,发现是数据格式的问题

    评论

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮