繁体   English   中英

尝试使用 Tensorflow Object 检测 API train.py 文件或 model_main_tf2.py 时出错

[英]Error while trying to use Tensorflow Object Detection API train.py file or model_main_tf2.py

I am having some issues as I am trying to use Tensorflow's Object Detection API for an object detection model I try to set up. 我一直有一个 Unicode 错误,无论我使用 train.py 还是 model_main_tf2.py 文件似乎都相似,但似乎无法正确定位该错误。 这是我使用的代码和错误。 我的系统在 Windows 10 上运行。提前感谢您的回答和/或提示。

命令:

.python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/EffDetD0.config

错误:

2021-11-26 15:24:15.527841: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2021-11-26 15:24:19.597360: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-11-26 15:24:19.597749: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cublas64_11.dll'; dlerror: cublas64_11.dll not found
2021-11-26 15:24:19.598123: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cublasLt64_11.dll'; dlerror: cublasLt64_11.dll not found
2021-11-26 15:24:19.601296: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cusolver64_11.dll'; dlerror: cusolver64_11.dll not found
2021-11-26 15:24:19.601686: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cusparse64_11.dll'; dlerror: cusparse64_11.dll not found
2021-11-26 15:24:19.602067: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudnn64_8.dll'; dlerror: cudnn64_8.dll not found
2021-11-26 15:24:19.602079: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1850] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
2021-11-26 15:24:19.602460: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
WARNING:tensorflow:There are non-GPU devices in `tf.distribute.Strategy`, not using nccl allreduce.
W1126 15:24:19.602859  6764 cross_device_ops.py:1387] There are non-GPU devices in `tf.distribute.Strategy`, not using nccl allreduce.
INFO:tensorflow:Using MirroredStrategy with devices ('/job:localhost/replica:0/task:0/device:CPU:0',)
I1126 15:24:19.607062  6764 mirrored_strategy.py:376] Using MirroredStrategy with devices ('/job:localhost/replica:0/task:0/device:CPU:0',)
Traceback (most recent call last):
  File "model_main_tf2.py", line 115, in <module>
    tf.compat.v1.app.run()
  File "C:\Users\ishma\anaconda3\lib\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\ishma\anaconda3\lib\site-packages\absl\app.py", line 312, in run
    _run_main(main, args)
  File "C:\Users\ishma\anaconda3\lib\site-packages\absl\app.py", line 258, in _run_main
    sys.exit(main(argv))
  File "model_main_tf2.py", line 112, in main
    record_summaries=FLAGS.record_summaries)
  File "C:\Users\ishma\anaconda3\lib\site-packages\object_detection\model_lib_v2.py", line 499, in train_loop
    pipeline_config_path, config_override=config_override)
  File "C:\Users\ishma\anaconda3\lib\site-packages\object_detection\utils\config_util.py", line 138, in get_configs_from_pipeline_file
    proto_str = f.read()
  File "C:\Users\ishma\anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 118, in read
    self._preread_check()
  File "C:\Users\ishma\anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 81, in _preread_check
    compat.path_to_str(self.__name), 1024 * 512)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 81: invalid start byte```

第一个答案

尝试将这些行添加到model_main_tf2.py以检查输入是否正确插入到脚本中。

...
## add the three prints to inspect the inputs fo the script
    with strategy.scope():
      print('🔴', FLAGS.pipeline_config_path)
      print('🔴', FLAGS.model_dir)
      print('\n\n\n')
...

我遇到了同样的问题,在将这些行添加到代码中后,我发现脚本正在为pipeline.config文件获取 None 。 因此,经过一番调查,在脚本命令中出现拼写错误的单词是我的错。

第二个答案

从我在您的错误中可以看到,您的文件pipeline.config可能未以 utf-8 格式保存。 尝试将其更改为 utf-8 格式。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM