object_detection - ImportError: cannot import name 'dataset_builder'

object_detection - ImportError: cannot import name 'dataset_builder'

我最近更新到 tf 1.5 并尝试在 research/object_detection 下调用 train.py 时遇到错误说

更多信息:

Traceback (most recent call last):
  File "train.py", line 50, in <module>
    from object_detection.builders import dataset_builder
ImportError: cannot import name 'dataset_builder'

是否存在任何循环依赖或者只有我得到这个错误?或者在您这边一切正常?

如果您在代码中注意到 dataset_builder 是从 object_detection.builders 调用的,这意味着您必须从一个目录向上(从研究目录)执行代码。就我而言,我只是将 train.py 代码移动到研究目录,然后正常发布它并且它起作用了!

我遇到了同样的问题(使用 Tensorflow 1.7.0),但我通过更新 models/research/object_detection files, i.e. pulling the latest updates from the repository: https://github.com/tensorflow/models.git.

解决了这个问题

我假设我使用的预训练模型比本地 object_detection 文件更新。