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

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
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?