无效的参数错误Tensorflow对象检测训练

时间:2019-05-28 17:13:06

标签: tensorflow rgb tensor object-recognition

我正在按照张量流API训练张量流对象检测。过去,我使用完全相同的步骤训练了许多模型。但是,该模型不断向我显示以下错误消息。错误消息参考

InvalidArgumentError:image_size必须包含3个元素[4]

我搜索了错误并找到

InvalidArgumentError: image_size must contain 3 elements[4] #3349

显示错误并提供检查解决方案以确保所有图像均为RGB。我使用了该线程中提供的代码来检查所有图像。我发现约有15张不是RGB的图像。我删除了图像和相应的xml文件。我重新编译了csv文件和tfrecord文件,并重新开始了培训。我再次收到错误消息。然后,我尝试重新开始训练而没有从上一个检查点恢复,并且仍然收到错误。该错误不会定期发生。有时,模型在失败之前会经过数千步。我也尝试过从pipeline.config文件中删除没有影响的随机裁剪参数。

感谢您的帮助。

错误消息:

INFO:tensorflow:global_step/sec: 2.03361
INFO:tensorflow:global step 4039: loss = 6.2836 (0.512 sec/step)
INFO:tensorflow:Error reported to Coordinator: <class 'tensorflow.python.framework.errors_impl.InvalidArgumentError'>, image_size must contain 3 elements[4]
         [[Node: cond_2/RandomCropImage/sample_distorted_bounding_box/SampleDistortedBoundingBoxV2 = SampleDistortedBoundingBoxV2[T=DT_INT32, area_range=[0.1, 1], aspect_ratio_range=[0.5, 2],max_attempts=100, seed=0, seed2=0, use_image_if_no_bounding_boxes=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](cond_2/RandomCropImage/Shape, cond_2/RandomCropImage/ExpandDims, cond_2/RandomCropImage/PruneNonOverlappingBoxes/Const)]]
INFO:tensorflow:Recording summary at step 4039.
INFO:tensorflow:global step 4040: loss = 4.6984 (0.880 sec/step)
INFO:tensorflow:Finished training! Saving model to disk.
Traceback (most recent call last):
  File "/floyd/object_detection/legacy/train.py", line 184, in <module>
    tf.app.run()
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, inrun
    _sys.exit(main(argv))
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 250, in new_func
    return func(*args, **kwargs)
  File "/floyd/object_detection/legacy/train.py", line 180, in main
    graph_hook_fn=graph_rewriter_fn)
  File "/floyd/object_detection/legacy/trainer.py", line 415, in train
    saver=saver)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/contrib/slim/python/slim/learning.py", line 785, in train
    ignore_live_threads=ignore_live_threads)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/training/supervisor.py", line 833, in stop
    ignore_live_threads=ignore_live_threads)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/training/coordinator.py", line389, in join
    six.reraise(*self._exc_info_to_raise)
  File "/usr/local/lib/python3.6/site-packages/six.py", line 693, in reraise
    raise value
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/training/queue_runner_impl.py", line 252, in _run
    enqueue_callable()
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1244,in _single_operation_run
    self._call_tf_sessionrun(None, {}, [], target_list, None)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1409,in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: image_size must contain 3 elements[4]
         [[Node: cond_2/RandomCropImage/sample_distorted_bounding_box/SampleDistortedBoundingBoxV2 = SampleDistortedBoundingBoxV2[T=DT_INT32, area_range=[0.1, 1], aspect_ratio_range=[0.5, 2],max_attempts=100, seed=0, seed2=0, use_image_if_no_bounding_boxes=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](cond_2/RandomCropImage/Shape, cond_2/RandomCropImage/ExpandDims, cond_2/RandomCropImage/PruneNonOverlappingBoxes/Const)]]

先谢谢了。

1 个答案:

答案 0 :(得分:0)

所以这是RGB图像问题。我已经检查了图像并删除了非RGB图像并重新创建了记录,但是该模型仍指向旧记录,因为路径非常相似,我没有注意到。