-
Notifications
You must be signed in to change notification settings - Fork 11.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: module 'tensorflow' has no attribute 'log' #1797
Comments
Hi @bsivavenu you might want to downgrade your tensorflow version. I think you are running ver. 2.0 |
thx for reply, which version i shd install, there is no specific version mentioned, i cn downgrade upto 1.13 only, hw shd i proceed ? |
- Tensorflow 2.0 is not compatible with demo.ipynb due to removal of log function, potentially among others - Fixes matterport#1797
Maybe you can try lower version of tensorflow like 1.4, |
I tried all tensorflow versions 1.13-2.0 and I still get the same errors. Any updates regarding this thread? Thanks ! |
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>.
|
If you can find the exact line where |
Could you figure out the solution? I'm facing the same issue too. |
Could you be specific as to what version of tensorflow I should downgrade mine to? |
I have tried that but unfortunately it doesn't work. |
So I managed to fix the issue. There are two solutions. Or you can create a separate environment with TensorFlow version 1.13.1 and keras 2.1.0. It should do the trick :) |
It still use old version of tf library. I'll copy+paste changed code here and you use and compare yourself. Summary:
click to view the code block``` """ Mask R-CNN The main Mask R-CNN model implementation.Copyright (c) 2017 Matterport, Inc. import os from mrcnn import utils Requires TensorFlow 1.3+ and Keras 2.0.8+.from distutils.version import LooseVersion ############################################################ Utility Functions############################################################ def log(text, array=None): class BatchNorm(KL.BatchNormalization):
def compute_backbone_shapes(config, image_shape):
############################################################ Resnet Graph############################################################ Code adopted from:https://github.com/fchollet/deep-learning-models/blob/master/resnet50.pydef identity_block(input_tensor, kernel_size, filters, stage, block,
def conv_block(input_tensor, kernel_size, filters, stage, block,
def resnet_graph(input_image, architecture, stage5=False, train_bn=True): ############################################################ Proposal Layer############################################################ def apply_box_deltas_graph(boxes, deltas): def clip_boxes_graph(boxes, window): class ProposalLayer(KE.Layer):
############################################################ ROIAlign Layer############################################################ def log2_graph(x): class PyramidROIAlign(KE.Layer):
############################################################ Detection Target Layer############################################################ def overlaps_graph(boxes1, boxes2): def detection_targets_graph(proposals, gt_class_ids, gt_boxes, gt_masks, config):
class DetectionTargetLayer(KE.Layer):
############################################################ Detection Layer############################################################ def refine_detections_graph(rois, probs, deltas, window, config):
class DetectionLayer(KE.Layer):
############################################################ Region Proposal Network (RPN)############################################################ def rpn_graph(feature_map, anchors_per_location, anchor_stride):
def build_rpn_model(anchor_stride, anchors_per_location, depth):
############################################################ Feature Pyramid Network Heads############################################################ def fpn_classifier_graph(rois, feature_maps, image_meta,
def build_fpn_mask_graph(rois, feature_maps, image_meta,
############################################################ Loss Functions############################################################ def smooth_l1_loss(y_true, y_pred): def rpn_class_loss_graph(rpn_match, rpn_class_logits):
def rpn_bbox_loss_graph(config, target_bbox, rpn_match, rpn_bbox):
def mrcnn_class_loss_graph(target_class_ids, pred_class_logits,
def mrcnn_bbox_loss_graph(target_bbox, target_class_ids, pred_bbox):
def mrcnn_mask_loss_graph(target_masks, target_class_ids, pred_masks):
############################################################ Data Generator############################################################ def load_image_gt(dataset, config, image_id, augment=False, augmentation=None,
def build_detection_targets(rpn_rois, gt_class_ids, gt_boxes, gt_masks, config):
def build_rpn_targets(image_shape, anchors, gt_class_ids, gt_boxes, config):
def generate_random_rois(image_shape, count, gt_class_ids, gt_boxes):
def data_generator(dataset, config, shuffle=True, augment=False, augmentation=None,
############################################################ MaskRCNN Class############################################################ class MaskRCNN():
############################################################ Data Formatting############################################################ def compose_image_meta(image_id, original_image_shape, image_shape,
def parse_image_meta(meta):
def parse_image_meta_graph(meta):
def mold_image(images, config): def unmold_image(normalized_images, config): ############################################################ Miscellenous Graph Functions############################################################ def trim_zeros_graph(boxes, name='trim_zeros'):
def batch_pack_graph(x, counts, num_rows): def norm_boxes_graph(boxes, shape):
def denorm_boxes_graph(boxes, shape):
|
Hi, I managed to run the code on tensorflow v2 without manually editing the code. There is a script that automatically migrates old TF-1 code to TF-2 code. From terminal just execute:
The script is part of TensorFlow 2. I've taken the above code from this official guide. It should fix the issue. |
Hey, I've tested the official upgrade command. First I was in the project folder, then I
Since I don't need another backup, I use the following command, according to the help instruction.
Mask_RCNN is where I clone the whole repo. |
Please use these specifications : as the requirements.txt file |
in model.py you should change: and then |
IF you are using TF2.0 then |
Hi mouhannadali, |
@soliverc tf.log -> tf.math.log solved my probem. |
May I ask which versions of python and keras you are using |
➜ ~ pip show tensorflow
Name: tensorflow
Version: 2.1.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: ~/.local/lib/python3.6/site-packages
Requires: protobuf, grpcio, google-pasta, keras-preprocessing, tensorboard, tensorflow-estimator, astunparse, absl-py, numpy, six, termcolor, wheel, scipy, h5py, wrapt, gast, opt-einsum
Required-by:
➜ ~ pip show keras
Name: Keras
Version: 2.3.1
Summary: Deep Learning for humans
Home-page: https://github.com/keras-team/keras
Author: Francois Chollet
Author-email: francois.chollet@gmail.com
License: MIT
Location: ~/.local/lib/python3.6/site-packages/Keras-2.3.1-py3.6.egg
Requires: numpy, scipy, six, pyyaml, h5py, keras-applications, keras-preprocessing
Required-by:
➜ ~ python --version
Python 3.6.9 |
All same but it didn't work for me. I wonder if I'm doing it wrong. Which model file did you edit? Can you give me the cd |
I had the same issue. i am using tensorflow 2.1.0, python 3.6.10 and keras 2.3.1 there is 2 different .py files u have to edit. one of them is model.py and the other one is utils.py both of them is under "C:\Anaconda3\envs"YOUR ENV NAME"\Lib\site-packages\mrcnn" direction for me. |
Hello everybody, this is the code running from google colaboratory. |
Thanks for this. |
You are a star. |
Thank you bro |
Did you solve this? |
Oh then that might be the problem. I am using jupyter notebook. Thanks! |
You welcome
Le jeu. 21 mai 2020 à 11:31, StijnBerendse <notifications@github.com> a
écrit :
… Oh then that might be the problem. I am using jupyter notebook. Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1797 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/API7ULFN22POPCIQUNWJP23RSUGKXANCNFSM4JA7FMBQ>
.
|
If it's working tell me
Le jeu. 21 mai 2020 à 11:32, ayoub lahkim <ayoublahkim2018@gmail.com> a
écrit :
… You welcome
Le jeu. 21 mai 2020 à 11:31, StijnBerendse ***@***.***> a
écrit :
> Oh then that might be the problem. I am using jupyter notebook. Thanks!
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#1797 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/API7ULFN22POPCIQUNWJP23RSUGKXANCNFSM4JA7FMBQ>
> .
>
|
Thanks
Thanks dude its working ! |
Help me pleas Traceback (most recent call last): |
still, this didn't work for me. I got this one: --> 341 return tf.math.log(x) / tf.math.log(2.0) AttributeError: module 'tensorflow' has no attribute 'log' |
Hi, I tried this but still getting the I am using Kaggle with tensorflow version 2.2.0 |
That works. Thank you! |
It works ! Thank you very much ! |
i am getting error on tf has no attribute log using tensorflow v 2.2 or higher and keras 2.3.4 and also it does not work on lower versions in colab ? Can anyone have any idea how to do it ? Except v 1.4, it doesn't work with all versions. But v 1.4 have compatibility issue with keras. |
Hi! kindly see this issue #2312 there is a pointer to the same implementation that supports TensorFlow 2=> (with GPU). If this solves your problem kindly close the issue so as others can navigate to other issues easier |
I just replaced tf.logging by tf.compat.v1.logging in my code, |
For me also required: |
Would you please tell me in which line it is in the model.py file? because I search but I didn't find it. |
I tried to upgrade my code from tf.v1 to tf.v2 but still it is showing me same error. Please help. |
I currently have 2.3.1 version of TensorFlow installed. How do I get the lower version? |
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? |
change the following portion of code in 'requirements.txt' tensorflow>=1.3.0 to tensorflow==1.3.0 |
matterport#1070 and matterport#1070 (comment) tensorflow/tensorflow#43982 and tensorflow/tensorflow#43982 (comment) matterport#2252 and matterport#2252 (comment) See the diff to see where everything was updated for 2021 using python 3 and latest versions of tensorflow and keras. As of this commit, the demo.ipynb runs and displays images as expected.
It is found in Mask_RCNN--> mrcnn |
https://www.immersivelimit.com/tutorials/mask-rcnn-for-windows-10-tensorflow-2-cuda-101 I tried this and works fine. |
code change 1. import keras.engine as KE -> import keras.engine.topology as KE 2. from keras import saving -> from tensorflow.python.keras.saving import hdf5_format 3. saving.load_weights_from_hdf5_group(f, layers) -> hdf5_format.load_weights_from_hdf5_group(f, layers) 4. import tensorflow as tf -> import tensorflow.compat.v1 as tf 5. indices = tf.stack([tf.range(probs.shape[0]), class_ids], axis=1) -> indices = tf.stack([tf.range(tf.shape(probs)[0]), class_ids], axis = 1) 6. mrcnn_bbox = layers.Reshape((-1, num_classes, 4), name="mrcnn_bbox")(x) -> if s[1]==None: mrcnn_bbox = layers.Reshape((-1, num_classes, 4), name="mrcnn_bbox")(x) else: mrcnn_bbox = KL.Reshape((s[1], num_classes, 4), name="mrcnn_bbox")(x) 7. indices = tf.stack([tf.range(probs.shape[0]), class_ids], axis=1) -> indices = tf.stack([tf.range(tf.shape(probs)[0]), class_ids], axis = 1) 8. from keras import saving -> from tensorflow.python.keras import saving https://stackoverflow.com/questions/67905185/module-keras-engine-has-no-attribute-layer matterport#2252 (comment) matterport#1797 (comment) matterport#1070 (comment) matterport#1070 (comment)
I tried it, It's working, Thanks. |
Hi @xenogew |
I struggled for a bit with both the outdated Keras and Tensorflow versions on this repo. |
https://pythondev.space/questions/transforming-a-tensor-of-row-column-pairs-into-a-boolean-mask-using-tensorflow I dealt with that issue and found the solution |
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
The text was updated successfully, but these errors were encountered: