【问题标题】:python Tensorflow 2.4.0 'input must be 4-dimensional[1,1,371,300,3]' ERRORpython Tensorflow 2.4.0'输入必须是4维[1,1,371,300,3]'错误
【发布时间】:2021-09-12 06:37:42
【问题描述】:

我正在运行 Nicholas Rennote 的 TFODCourse。 当我执行评估模型代码时:

python Tensorflow\models\research\object_detection\model_main_tf2.py --model_dir=Tensorflow\workspace\models\my_ssd_mobnet --pipeline_config_path=Tensorflow\workspace\models\my_ssd_mobnet\pipeline.config --checkpoint_dir=Tensorflow\workspace\models\my_ssd_mobnet

出现这样的错误

Traceback (most recent call last):
  File "Tensorflow\models\research\object_detection\model_main_tf2.py", line 115, in <module>
    tf.compat.v1.app.run()
  File "C:\Users\All_Nighter\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\platform\app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "C:\Users\All_Nighter\miniconda3\envs\TF\lib\site-packages\absl\app.py", line 303, in run
    _run_main(main, args)
  File "C:\Users\All_Nighter\miniconda3\envs\TF\lib\site-packages\absl\app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "Tensorflow\models\research\object_detection\model_main_tf2.py", line 82, in main
    model_lib_v2.eval_continuously(
  File "C:\Users\All_Nighter\miniconda3\envs\TF\lib\site-packages\object_detection-0.1-py3.8.egg\object_detection\model_lib_v2.py", line 1151, in eval_continuously
    eager_eval_loop(
  File "C:\Users\All_Nighter\miniconda3\envs\TF\lib\site-packages\object_detection-0.1-py3.8.egg\object_detection\model_lib_v2.py", line 928, in eager_eval_loop
    for i, (features, labels) in enumerate(eval_dataset):
  File "C:\Users\All_Nighter\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\data\ops\iterator_ops.py", line 761, in __next__
    return self._next_internal()
  File "C:\Users\All_Nighter\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\data\ops\iterator_ops.py", line 744, in _next_internal
    ret = gen_dataset_ops.iterator_get_next(
  File "C:\Users\All_Nighter\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\ops\gen_dataset_ops.py", line 2727, in iterator_get_next
    _ops.raise_from_not_ok_status(e, name)
  File "C:\Users\All_Nighter\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\framework\ops.py", line 6897, in raise_from_not_ok_status
    six.raise_from(core._status_to_exception(e.code, message), None)
  File "<string>", line 3, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: input must be 4-dimensional[1,1,371,300,3]
         [[{{node ResizeImage/resize/ResizeBilinear}}]] [Op:IteratorGetNext]

我不明白input must be 4-dimensional[1,1,371,300,3] 是什么意思。 我再次尝试标注,并将 TF 降级到 2.4.0。但还是发生了。

【问题讨论】:

    标签: python-3.x tensorflow object-detection


    【解决方案1】:

    ssd_mobilenet 模型需要输入

    可变大小的三通道图像 - 模型不支持 配料。输入张量是一个 tf.uint8 张量,形状为 [1, height, width, 3] 的值为 [0, 255]

    在这种情况下,您给出的是 4 维输入[1,1,371,300,3], 将您的输入数据重塑为[1,371,300,3]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-12
      • 2017-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-03
      • 2012-12-16
      • 1970-01-01
      相关资源
      最近更新 更多