简体   繁体   中英

AttributeError: module 'tensorflow._api.v1.compat' has no attribute 'v2' For Tensorflow Object Detection API

I'm working on Tensorflow Object Detection API on Python. I'm training a custom object detection algorithm and the pretrained model which is been used is ssd_mobilenet_v1_pets.config when I try to run train.py from the legacy folder from Models/object_detection i get this particular error

 Traceback (most recent call last):
  File "train.py", line 48, in <module>
    from object_detection.builders import model_builder
  File "C:\Users\Captain\AppData\Local\Programs\Python\Python36\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\Captain\AppData\Local\Programs\Python\Python36\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\Captain\AppData\Local\Programs\Python\Python36\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 "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
  File "C:\Users\Captain\AppData\Local\Programs\Python\Python36\lib\site-packages\slim-0.1-py3.6.egg\nets\mobilenet\mobilenet.py", line 399, in <module>
AttributeError: module 'tensorflow._api.v1.compat' has no attribute 'v2'

I have

  1. Tensorflow 1.13.2
  2. Python 3.6
  3. Windows 10

This is the command I'm trying to run on windows command prompt.

python train.py --logtostderr --train_dir=Users/Captain/Desktop/ANPR V1/ --pipeline_config_path=Users/Captain/Desktop/ANPR V1/ssd_inception_v2_coco.config

I thought it might be because I was using another model so also tried this command

python train.py --logtostderr --train_dir=Users/Captain/Desktop/ANPR V1/ --pipeline_config_path=Users/Captain/Desktop/ANPR V1/ssd_mobilenet_v1_pets.config

but I got the same error

I faced the same problem. If you downloaded the latest repository of tensorflow models then try downloading this tensorflow models of version 1.13.0 instead the latest repo as you are using Tensorflow 1.13.2. It solved my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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