zuruoke/watermark-removal

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

amirhossein303 opened this issue · 2 comments

I have installed tenserflow 2.11 with python 3.10

then when i run the code

!  python main.py --image pic1.jpeg --output res2.jpg --checkpoint_dir model/ --watermark_type istock

the following error will show

2022-12-01 17:24:41.275524: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-12-01 17:24:41.413694: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/user/fun/python/watermark-removal/venv/lib/python3.10/site-packages/cv2/../../lib64:
2022-12-01 17:24:41.413720: I tensorflow/compiler/xla/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2022-12-01 17:24:42.047465: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/user/fun/python/watermark-removal/venv/lib/python3.10/site-packages/cv2/../../lib64:
2022-12-01 17:24:42.047536: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/user/fun/python/watermark-removal/venv/lib/python3.10/site-packages/cv2/../../lib64:
2022-12-01 17:24:42.047547: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
Traceback (most recent call last):
  File "/home/user/fun/python/watermark-removal/main.py", line 8, in <module>
    import neuralgym as ng
  File "/home/user/fun/python/watermark-removal/venv/lib/python3.10/site-packages/neuralgym/__init__.py", line 27, in <module>
    from . import callbacks
  File "/home/user/fun/python/watermark-removal/venv/lib/python3.10/site-packages/neuralgym/callbacks/__init__.py", line 3, in <module>
    from .hyper_param_scheduler import HyperParamScheduler
  File "/home/user/fun/python/watermark-removal/venv/lib/python3.10/site-packages/neuralgym/callbacks/hyper_param_scheduler.py", line 6, in <module>
    from ..ops.summary_ops import scalar_summary
  File "/home/user/fun/python/watermark-removal/venv/lib/python3.10/site-packages/neuralgym/ops/__init__.py", line 4, in <module>
    from . import layers
  File "/home/user/fun/python/watermark-removal/venv/lib/python3.10/site-packages/neuralgym/ops/layers.py", line 93, in <module>
    activation_fn=None, w_init=tf.contrib.layers.xavier_initializer_conv2d(),
AttributeError: module 'tensorflow' has no attribute 'contrib'

How can i fix this problem?

how do you resolve this? @amirhosseinzibaei

Well, i used conda and create an environment with python version 3.6 then install requirements
Actually in past, I was using the new version of tenserflow 2, but as this repository says, its need tenserflow 1.15
So that fixed my little problem