matterport / Mask_RCNN

Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow
Other
24.66k stars 11.7k forks source link

AttributeError: module 'tensorflow' has no attribute 'log' #1797

Open bsivavenu opened 5 years ago

bsivavenu commented 5 years ago

i downloaded mask_rcnn_coco.h5 weights and installed pycocotools also and when i try to run demo.ipynb. i am getting this error as AttributeError: module 'tensorflow' has no attribute 'log' , please help i am still learning. I installed all the requoremnts.txt file also. please help.


**AttributeError Traceback (most recent call last)

in 1 # Create model object in inference mode. ----> 2 model = modellib.MaskRCNN(mode="inference", model_dir=MODEL_DIR, config=config) 3 4 # Load weights trained on MS-COCO 5 model.load_weights(COCO_MODEL_PATH, by_name=True)** this is the error im getting
nickums commented 4 years ago

I just replaced tf.logging by tf.compat.v1.logging in my code, which required the trick for tf.app

sunnybear commented 4 years ago

For me also required: tf.cast(tf.gather(class_ids, keep)) -> tf.cast(tf.gather(class_ids, keep), tf.float32) so totally 5 replaces in model.py

sahaj432 commented 4 years ago

If you can find the exact line where tf.log is used, try tf.math.log instead.

Would you please tell me in which line it is in the model.py file? because I search but I didn't find it.

sahaj432 commented 4 years ago

Hey, I've tested the official upgrade command. First I was in the project folder, then I cd .. Since I don't need another backup, I use the following command, according to the help instruction. tf_upgrade_v2 --intree Mask_RCNN --inplace --reportfile report.txt Mask_RCNN is where I clone the whole repo. And it works.

Hi, I tried this but still getting the AttributeError: module 'tensorflow' has no attribute 'log'

I am using Kaggle with tensorflow version 2.2.0

I tried to upgrade my code from tf.v1 to tf.v2 but still it is showing me same error. Please help.

HariChandana27 commented 3 years ago

Thanks Ahmad! It worked for me by running a completely independent virtual environment with a fresh install and specific tensor flow=1.13.1 and keras=2.1.0 versions Rami On Nov 26, 2019, at 11:02 AM, ahmadasghar1992 @.***> wrote: I got it solved by downloading the shapely (.whl) file manually. Download the file from the following link. Be sure to check the Python version. Mine is Python 3.6 with Win 10 64 so I downloaded Shapely-1.6.4.post2-cp36-cp36m-win_amd64. Yours can be different, be sure to check. Link to download the file https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#1797?email_source=notifications&email_token=AMLN7INB4MZIPCMLEGAIAVLQVVCBLA5CNFSM4JA7FMB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFGQX6A#issuecomment-558697464>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMLN7IMASHWZIMVJU257Y73QVVCBLANCNFSM4JA7FMBQ.

I currently have 2.3.1 version of TensorFlow installed. How do I get the lower version?

Genius-farmer commented 3 years ago

Dear All,

After adjusting the Tensorflow version according to the advices above.

I got an error message "TypeError: expected string or bytes-like object"

Any advice what to do?

fahim5466 commented 3 years ago

change the following portion of code in 'requirements.txt'

tensorflow>=1.3.0 keras>=2.0.8

to

tensorflow==1.3.0 keras==2.0.8

Al-Badri179 commented 3 years ago

change the following portion of code in 'requirements.txt'

tensorflow>=1.3.0 keras>=2.0.8

to

tensorflow==1.3.0 keras==2.0.8

If you can find the exact line where tf.log is used, try tf.math.log instead.

Would you please tell me in which line it is in the model.py file? because I search but I didn't find it.

It is found in Mask_RCNN--> mrcnn

herossa commented 3 years ago

https://www.immersivelimit.com/tutorials/mask-rcnn-for-windows-10-tensorflow-2-cuda-101

I tried this and works fine.

piaozhegao commented 3 years ago

If you can find the exact line where tf.log is used, try tf.math.log instead.

I tried it, It's working, Thanks.

mansi-aggarwal-2504 commented 3 years ago

It still use old version of tf library. So what I did is find the replacement functions and replace it on model.py file.

I'll copy+paste changed code here and you use and compare yourself.

Summary:

  • tf.log() -> tf.math.log()
  • tf.sets.set_intersection() -> tf.sets.intersection()
  • tf.sparse_tensor_to_dense() -> tf.sparse.to_dense()
  • tf.to_float() -> tf.cast([value], tf.float32)

click to view the code block

Hi @xenogew I tried replacing all functions as mentioned here but I am still getting this error. Earlier, I was getting this error: TypeError: Could not build a TypeSpec for <KerasTensor: shape=(None, None, 4) So I tried what's mentioned here and I got this log error and was redirected here. But I am still getting the log error.

ivarmak commented 2 years ago

I struggled for a bit with both the outdated Keras and Tensorflow versions on this repo. If you want to use the current versions, instead of replacing lines I recommend you cloning the following repo: https://github.com/akTwelve/Mask_RCNN It has been updated to run on tensorflow v2+ and keras v2.