简体   繁体   English

Tensorflow 对象检测 AttributeError:模块“tensorflow._api.v1.compat”没有属性“v2”

[英]Tensorflow Object Detection AttributeError: module 'tensorflow._api.v1.compat' has no attribute 'v2'

Currently running TF 1.13.2当前运行 TF 1.13.2

I'm trying to train my own object detection model.我正在尝试训练我自己的对象检测模型。 After trying to run this command:尝试运行此命令后:

python model_main.py --logtostderr --model_dir=training/ --pipeline_config_path=traini
ng/faster_rcnn_inception_v2_pets.config

I get this error:我收到此错误:

Traceback (most recent call last):
  File "model_main.py", line 26, in <module>
    from object_detection import model_lib
  File "C:\Users\Admin\Anaconda3\envs\object_detection\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\model_lib.py", line 28, in <module>
    from object_detection import exporter as exporter_lib
  File "C:\Users\Admin\Anaconda3\envs\object_detection\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\exporter.py", line 24, in <module>
    from object_detection.builders import model_builder
  File "C:\Users\Admin\Anaconda3\envs\object_detection\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\builders\model_builder.py", line 47, in <module>
    from object_detection.models.ssd_mobilenet_edgetpu_feature_extractor import SSDMobileNetEdgeTPUFeatureExtractor
  File "C:\Users\Admin\Anaconda3\envs\object_detection\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\models\ssd_mobilenet_edgetpu_feature_extractor.py", line
 19, in <module>
    from object_detection.models import ssd_mobilenet_v3_feature_extractor
  File "C:\Users\Admin\Anaconda3\envs\object_detection\lib\site-packages\object_detection-0.1-py3.6.egg\object_detection\models\ssd_mobilenet_v3_feature_extractor.py", line 25,
in <module>
    from nets.mobilenet import mobilenet
  File "C:\Users\Admin\Desktop\ObjectDetection\models\research\object_detection\nets\mobilenet\mobilenet.py", line 399, in <module>
    def global_pool(input_tensor, pool_op=tf.compat.v2.nn.avg_pool2d):
AttributeError: module 'tensorflow._api.v1.compat' has no attribute 'v2'

I need to stay below TF 2.x because 2.x does not yet allow for training your own model (according to Gilbert Tanner's object detection tutorial).我需要保持在 TF 2.x 以下,因为 2.x 还不允许训练你自己的模型(根据 Gilbert Tanner 的对象检测教程)。 I've bounced around between TF versions and I've gotten similar errors in different versions that some module has no attribute 'v1'.我在 TF 版本之间徘徊,并且在不同版本中遇到了类似的错误,即某些模块没有属性“v1”。 In either case, I'm not sure at all how to fix this.在任何一种情况下,我都不确定如何解决这个问题。

Edit: Here are the site-packages for my environment:编辑:以下是我的环境的站点包:

Package Version Latest Version
absl-py 0.9.0   0.8.1
astor   0.8.1   0.8.0
biwrap  0.1.6   
bleach  1.5.0   3.1.0
certifi 2019.11.28  2019.11.28
gast    0.3.3   0.3.2
grpcio  1.27.0  1.16.1
h5py    2.10.0  2.10.0
html5lib    1.000000    1.0.1
keras-applications  1.0.8   1.0.8
keras-preprocessing 1.1.0   1.1.0
markdown    3.1.1   3.1.1
mock    3.0.5   3.0.5
numpy   1.18.1  1.18.1
object-detection    0.100000    
pandas  1.0.0   1.0.0
pillow  7.0.0   7.0.0
pip 20.0.2  20.0.2
protobuf    3.11.3  3.11.2
pycocotools 2.000000    
python  3.6.10  3.8.1
python-dateutil 2.8.1   2.8.1
pytz    2019.300000 2019.300000
setuptools  39.1.0  45.1.0
six 1.14.0  1.14.0
sqlite  3.31.1  3.31.1
tensorboard 1.9.0   2.0.0
tensorflow  1.9.0   2.0.0
tensorflow-estimator    1.13.0  2.0.0
tensorflow-plot 0.3.0   
tensorflow-tensorboard  1.5.1   
termcolor   1.1.0   1.1.0
vc  14.100000   14.100000
vs2015_runtime  14.16.27012 14.16.27012
werkzeug    0.16.1  0.16.1
wheel   0.34.2  0.34.2
wincertstore    0.200000    0.200000

EDIT: from experience you are using a TF2 designed model in a TF1 application.编辑:根据您在 TF1 应用程序中使用 TF2 设计的模型的经验。

Did you clone the models from Github?你是从 Github 克隆模型的吗? The repository is based on the latest TF存储库基于最新的TF

You can use the models designed for 1.13 specifically: https://github.com/tensorflow/models/archive/v1.13.0.zip您可以使用专为 1.13 设计的模型: https : //github.com/tensorflow/models/archive/v1.13.0.zip

reboot to clear EXPORT PATH重新启动以清除导出路径

cd models/models-1.13.0/research/ cd 模型/模型-1.13.0/研究/

protoc object_detection/protos/*.proto --python_out=.

export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

cd ../../.. cd ../../..

python3 github/TensorFlow-object-detection-tutorial-master/5_part\ step\ by\ step\ custom\ object\ detection/train.py --logtostderr
--train_dir=training/ --pipeline_config_path=dataset/data1/faster_rcnn_inception_v2_coco_tf13.config

Solved the issue EDIT: made the TF training on GCP and on Edge (jetson nano) too, feel free to up if you need moar backup.解决了问题 编辑:也在 GCP 和 Edge (jetson nano) 上进行了 TF 培训,如果您需要 moar 备份,请随时进行。

source 来源

暂无
暂无

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

相关问题 AttributeError: 模块“tensorflow._api.v1.compat”没有用于 Tensorflow 对象检测 API 的属性“v2” - AttributeError: module 'tensorflow._api.v1.compat' has no attribute 'v2' For Tensorflow Object Detection API AttributeError:模块“ tensorflow._api.v1.compat.v1”没有属性“ pywrap_tensorflow” - AttributeError: module 'tensorflow._api.v1.compat.v1' has no attribute 'pywrap_tensorflow' AttributeError:模块 'tensorflow.compat.v2' 没有属性 'logging' - AttributeError: module 'tensorflow.compat.v2' has no attribute 'logging' AttributeError: 模块“tensorflow_core.compat.v1”没有属性“contrib” - AttributeError: module 'tensorflow_core.compat.v1' has no attribute 'contrib' AttributeError:模块“tensorflow._api.v1.compat.v1.nn”没有属性“avg_pool2d” - AttributeError: module 'tensorflow._api.v1.compat.v1.nn' has no attribute 'avg_pool2d' “tensorflow._api.v1.compat.v2.compat”没有属性“v2” - 'tensorflow._api.v1.compat.v2.compat' has no attribute 'v2' AttributeError: 模块 &#39;tensorflow.compat&#39; 没有属性 &#39;v1&#39; Tensorflow v: 1.10.0 - AttributeError: module 'tensorflow.compat' has no attribute 'v1' Tensorflow v: 1.10.0 AttributeError:加载 tf.compat.v1.train.SessionRunHook 时模块“tensorflow”没有属性“compat” - AttributeError: module 'tensorflow' has no attribute 'compat' when loading tf.compat.v1.train.SessionRunHook 属性 AttributeError:模块“tensorflow.compat.v2”没有属性“_internal_” - Attribute AttributeError: module 'tensorflow.compat.v2' has no attribute '_internal_' AttributeError:模块'tensorflow_core.compat.v2'没有属性'__internal__'(一周前工作?) - AttributeError: module 'tensorflow_core.compat.v2' has no attribute '__internal__' (Worked a week ago?)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM