leimao / DeepLab-V3

Google DeepLab V3 for Image Semantic Segmentation
https://leimao.github.io/project/DeepLab-V3/
MIT License
154 stars 48 forks source link

AttributeError: module 'tensorflow' has no attribute 'contrib' #9

Open Humphreybas opened 3 years ago

Humphreybas commented 3 years ago

followed the instruction for installation but bumped into this error when running train.py

$ python3 train.py
2021-02-19 23:20:37.098330: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2021-02-19 23:20:37.098358: 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.
Traceback (most recent call last):
  File "train.py", line 8, in <module>
    from model import DeepLab
  File ".../DeepLab-V3/model.py", line 6, in <module>
    from feature_extractor import MobileNet, Resnet, Vgg16
  File ".../DeepLab-V3/feature_extractor.py", line 2, in <module>
    from nets import resnet_v2
  File ".../DeepLab-V3/nets/resnet_v2.py", line 55, in <module>
    from nets import resnet_utils
  File ".../DeepLab-V3/nets/resnet_utils.py", line 43, in <module>
    slim = tf.contrib.slim
AttributeError: module 'tensorflow' has no attribute 'contrib'

I found some possible solutions here but couldn't figure it out..

Humphreybas commented 3 years ago

Ok I tried this command:

tf_upgrade_v2 \
  --intree DeepLab-V3/ \
  --outtree DeepLab-V3_tf2/ \
  --reportfile report.txt

But still got the same error when running training.py in the converted folder.

So I tried to downgrade tensorflow to 1.x: pip3 install tensorflow==1.15 pip gave me some errors about dependencies, so maybe I should have recreated my virtualenv completely with tensorflow==1.15 from the beginning instead of downgrading what was already installed.

But I run train.py anyway to see if it would work and it is running right now. So let's see if it finishes without problems.