Open hisham-zadfresh opened 3 years ago
Same here.
A pip freeze > out.txt
from someone who has the examples working would be nice. The provided requirements.txt is installing some jank that doesn't work together apparently.
I got the same error when trained with tensorflow 2.4
Have a look at #2427. Sounds like this will help
@RisingPhoelix I tried this solution, and it seems worked at first. And I will do more test with this repo and tensorflow 2.4.1. Thanks!
@panovr
Hi there,
I am suffering the same problem with tensorflow 2.4.1, could you give me some idea how to fix it?
many thanks
Anyone that fixed this problem? Facing the same issue
For me, it got fixed by selection tensorflow version %tensorflow_version 1.x
has anyone find any solution??
For me, it got fixed by selection tensorflow version %tensorflow_version 1.x
i tried the same but keras version is giving me problems. what is ur keras version? @nehakumar31
Have a look at #2427. Sounds like this will help
be sure to checkout the tesorflow2.0 branch
I got this error when I try to run this command:
python3 balloon.py train --dataset=/home/ubuntu/examples/research/mask-rcnn/samples/balloon/data --weights=coco
Traceback (most recent call last): File "balloon.py", line 330, in <module> model = modellib.MaskRCNN(mode="training", config=config, model_dir=args.logs) File "/home/ubuntu/examples/research/mask-rcnn/mrcnn/model.py", line 1837, in __init__ self.keras_model = self.build(mode=mode, config=config) File "/home/ubuntu/examples/research/mask-rcnn/mrcnn/model.py", line 1876, in build x, K.shape(input_image)[1:3]))(input_gt_boxes) File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py", line 952, in __call__ input_list) File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1091, in _functional_construction_call inputs, input_masks, args, kwargs) File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py", line 822, in _keras_tensor_symbolic_call return self._infer_output_signature(inputs, args, kwargs, input_masks) File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py", line 869, in _infer_output_signature keras_tensor.keras_tensor_from_tensor, outputs) File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tensorflow/python/util/nest.py", line 659, in map_structure structure[0], [func(*x) for x in entries], File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tensorflow/python/util/nest.py", line 659, in <listcomp> structure[0], [func(*x) for x in entries], File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/keras_tensor.py", line 606, in keras_tensor_from_tensor out = keras_tensor_cls.from_tensor(tensor) File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tensorflow/python/keras/engine/keras_tensor.py", line 205, in from_tensor type_spec = type_spec_module.type_spec_from_value(tensor) File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tensorflow/python/framework/type_spec.py", line 554, in type_spec_from_value (value, type(value).__name__)) TypeError: Could not build a TypeSpec for <KerasTensor: shape=(None, None, 4) dtype=float32 (created by layer 'tf.math.truediv')> with type KerasTensor
This happens in
mrcnn/model.py:1875
found out solution?
I resolve the problem and can work with below environment: python : 3.7.10 GPU : RTX3090ti pip install tensorflow==2.3.0 pip install tensorflow-gpu==2.3.0 pip install keras==2.4.3 cudatoolkit==11.0.221
Can solve above problem. But another problem produces:
ValueError:
The following Variables were created within a Lambda layer (anchors)but are not tracked by said layer:<tf.Variable 'anchors/Variable:0' shape=(2, 261888, 4) dtype=float32>The layer cannot safely ensure proper Variable reuse across multiple
calls, and consquently this behavior is disallowed for safety. Lambda layers are not well suited to stateful computation; instead, writing a subclassed Layer is the recommend way to define layers withVariables.
The Solutions : There are 2 choices -
anchors = KL.Lambda(lambda x: tf.Variable(anchors), name="anchors")(input_image)
to
class AnchorsLayer(KL.Layer):
def __init__(self, anchors, name="anchors", **kwargs):
super(AnchorsLayer, self).__init__(name=name, **kwargs)
self.anchors = tf.Variable(anchors)
def call(self, dummy):
return self.anchors
def get_config(self):
config = super(AnchorsLayer, self).get_config()
return config
anchors = AnchorsLayer(anchors, name="anchors")(input_image)
Hope to help you!
I have the same problem! My TensorFlow is also 2.4.1.
I had the same problem, when I replaced all the tf.compat.v1.where
by tf.where
along with that removed the tf.compat.v1.disable_eager_execution()
Once I put tf.compat.v1.disable_eager_execution()
back in the error disappears
Hi everyone, I am trying to concatenate basic MLP and EfficientNet to use both image features and meta data feature. But i got same error : Could not build a TypeSpec for <KerasTensor: shape=(None, 6) dtype=float32 (created by layer 'tf.concat_1')> with type KerasTensor
Can anyone help me please?
def build_model(): inputs = layers.Input(shape=(380, 380, 3)) x = img_augmentation(inputs) model = EfficientNetB4(include_top=False, input_tensor=x, weights="imagenet")
# Freeze the pretrained weights
model.trainable = False
# Rebuild top
x = layers.GlobalAveragePooling2D(name="avg_pool")(model.output)
top_dropout_rate = 0.2
x = layers.Dropout(top_dropout_rate, name="top_dropout2")(x)
outputs = layers.Dense(3, activation="softmax", name="pred3")(x)
model = tf.keras.Model(inputs, outputs, name="Transfer_Model")
for layer in model.layers[-20:]:
if not isinstance(layer, layers.BatchNormalization):
layer.trainable = True
return model
def create_mlp(dim,regularizer=None): """Creates a simple two-layer MLP with inputs of the given dimension""" model = Sequential() model.add(Dense(9, input_dim=dim, activation="relu",kernel_regularizer=regularizer )) model.add(Dense(3, activation="relu",name='second' )) return model mlp1 = create_mlp(3,regularizer=regularizers.l2(0.001)) eff = build_model()
Create the input to the final set of layers as the output of both the MLP and EficentNet combinedInput = concatenate([mlp1.output, eff.output])
Error is giving concatenate part. Thank you in advance !
I got this error when I try to run this command:
Traceback (most recent call last):
File "E:/PycharmProjects/Mask_RCNN-2.1/samples/balloon/balloon.py", line 330, in
python3.6 Keras2.4.3 TensorFlow2.5.0
Same problem here and I tried the solution provided by @linaouro, but it still doesn't work. Does anyone have an idea? Thank you in advance!
Google colab python 3.7 Tensorflow 2.4 Keras 2.4.3 cudatoolkit==11.0.2210
Traceback (most recent call last):
File "train.py", line 335, in
@enoceanwei Hi, I think we should use tensorflow v1, not v2.
@panovr But it will give another error because rest of part it made with v2.5
@Tzu-Jan I think you should upgrade your python to 3.8 My solution worked when I used tensorflow 2.4.0 with python3.8 (using the tf2 version of the net by https://github.com/leekunhee/Mask_RCNN/tree/tensorflow2.0)
@linaouro Hello Linaouro. Thanks for the leekunhee's version. But I have a problem. When I was running the following cell in train_shapes.ipynb.
model.train(dataset_train, dataset_val,
learning_rate=config.LEARNING_RATE,
epochs=1,
layers='heads')
The running button had stopped but the status bar was still executing. Should I wait it or there are some problems I have to solve.
@linaouro I figured out the problem. It had been executing 6 hours then interrupted because of running out of the GPU (Google Colab has a limit). I tried to run it again without GPU and it trained successfully. Thanks.
Hi everyone solved this problem on colab. python 3.7.10 !pip install 'h5py==2.10.0' --force-reinstall !pip uninstall keras-nightly !pip uninstall -y tensorflow !pip install tensorflow_gpu==2.4.0 !pip install keras==2.4.0 !pip install keras --user !pip uninstall keras-preprocessing !pip install git+https://github.com/keras-team/keras-preprocessing.git import tensorflow.compat.v1 as tf tf.disable_v2_behavior() tf.compat.v1.get_default_graph()
you should with this order on colab it worked for me !
Hi, I had the same problem on Colab Notebook. Python 3.7.10 Keras: 2.5.0 Tensorflow: 2.5.0 My solution: In file model.py:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
Replace the Lambda layer with subclass of Keras Layer() (mrcnn/model.py:1946), see
TypeError: Could not build a TypeSpec for <KerasTensor: shape=(None, None, 4) #2458 (comment) For the AttributeError about tf.log see AttributeError: module 'tensorflow' has no attribute 'log' #1797 (comment) and AttributeError: module 'tensorflow' has no attribute 'log' #1797 (comment)
Hi, I had the same problem on Colab Notebook. Python 3.7.10 Keras: 2.5.0 Tensorflow: 2.5.0 My solution: In file model.py:
import tensorflow.compat.v1 as tf tf.disable_v2_behavior() Replace the Lambda layer with subclass of Keras Layer() (mrcnn/model.py:1946), see
TypeError: Could not build a TypeSpec for <KerasTensor: shape=(None, None, 4) #2458 (comment) For the AttributeError about tf.log see AttributeError: module 'tensorflow' has no attribute 'log' #1797 (comment) and AttributeError: module 'tensorflow' has no attribute 'log' #1797 (comment)
Hi @agustinadinamarca, I did this and I am not getting the TypeError anymore but as mentioned in your comment, I am getting this error: AttributeError: module 'tensorflow' has no attribute 'log'
Which comment in the linked issue helped you? I tried this but I am still getting the log error.
Hi, I had the same problem on Colab Notebook. Python 3.7.10 Keras: 2.5.0 Tensorflow: 2.5.0 My solution: In file model.py:
import tensorflow.compat.v1 as tf tf.disable_v2_behavior() Replace the Lambda layer with subclass of Keras Layer() (mrcnn/model.py:1946), see
TypeError: Could not build a TypeSpec for <KerasTensor: shape=(None, None, 4) #2458 (comment) For the AttributeError about tf.log see AttributeError: module 'tensorflow' has no attribute 'log' #1797 (comment) and AttributeError: module 'tensorflow' has no attribute 'log' #1797 (comment)
Hi @agustinadinamarca, I did this and I am not getting the TypeError anymore but as mentioned in your comment, I am getting this error:
AttributeError: module 'tensorflow' has no attribute 'log'
Which comment in the linked issue helped you? I tried this but I am still getting the log error.
@mansi-aggarwal-2504 I have also the same error. Which version of the Mask RCNN source code do you use?
Hi @getgeosoft. I actually got caught up in errors due to version incompatibility issues. But I started afresh and created a new environment. Refer to this issue I raised. I hope this helps. P.S. I use Google Colab.
In addition to the two options which youreternity1997 provided, here is a third option. we can change : gt_boxes = KL.Lambda(lambda x: norm_boxes_graph(x, K.shape(input_image)[1:3]))(input_gt_boxes) #this for tf1 gt_boxes = KL.Lambda(lambda x: norm_boxes_graph2(x))([input_gt_boxes,input_image]) #this for tf2 where, def norm_boxes_graph2(x): boxes,tensor_for_shape = x shape = tf.shape(tensor_for_shape)[1:3] return norm_boxes_graph(boxes,shape)
@Tzu-Jan I think you should upgrade your python to 3.8 My solution worked when I used tensorflow 2.4.0 with python3.8 (using the tf2 version of the net by https://github.com/leekunhee/Mask_RCNN/tree/tensorflow2.0)
Is it possible that these changes are merged by the moderators of this repository? @waleedka
Also, why is this repository not actively maintained? despite people finding the use for it? I would be glad if I could help. Please guide me.
TypeError: Could not build a TypeSpec for KerasTensor(type_spec=TensorSpec(shape=(None, None, 4), dtype=tf.float32, name=None), name='tf.math.truediv/truediv:0', description="created by layer 'tf.math.truediv'") of unsupported type <class 'tensorflow.python.keras.engine.keras_tensor.KerasTensor'>.
i got this error when i try to run maskrcnn code
any one fix this error
TypeError: Could not build a TypeSpec for KerasTensor(type_spec=TensorSpec(shape=(None, None, 4), dtype=tf.float32, name=None), name='tf.math.truediv/truediv:0', description="created by layer 'tf.math.truediv'") of unsupported type <class 'tensorflow.python.keras.engine.keras_tensor.KerasTensor'>.
i got this error when i try to run maskrcnn code
any one fix this error
Try @rcx986635 answer You should make this change in the Mask_RCNN/mrcnn/model.py line 1875 (or somewhere around!)
For me, it got fixed by selection tensorflow version %tensorflow_version 1.x
Hey, I was able to fix that issue simply by installing tf-estimator-nightly in colab. Found that it was missing by trying what @yemre-data proposed. The following solution is simpler and also doesn't require to restart the runtime
!pip install tf-estimator-nightly==2.8.0.dev2021122109
This is what worked for me.
TensorFlow: 2.5.0 Keras: 2.6.0 Python: 3.7.0 Cuda: 11.2 Hope this helps!!!
Anyone that fixed this problem? Facing the same issue
yes, it take me 2 weeka now
I fixed the issue by Downgrading python and tensorflow. my env: cuda 11.2 tensorflow 2.5.0 keras 2.6.0 python 3.7.0
But i got another error info as following:
... order = _validate_interpolation_order(image.dtype, order) D:\env\python3.7.0\lib\site-packages\skimage\transform_warps.py:830: FutureWarning: Input image dtype is bool. Interpolation is not defined with bool data type. Please set order to 0 or explicitely cast input image to another data type. Starting from version 0.19 a ValueError will be raised instead of this warning. order = _validate_interpolation_order(image.dtype, order) 99/100 [============================>.] - ETA: 1s - batch: 49.0000 - size: 2.0000 - loss: 0.1762 - rpn_class_loss: 0.0042 - rpn_bbox_loss: 0.0259 - mrcnn_class_loss: 0.0279 - mrcnn_bbox_loss: 0.0312 - mrcnn_mask_loss: 0.0869D:\env\python3.7.0\lib\site-packages\skimage\transform_warps.py:830: FutureWarning: Input image dtype is bool. Interpolation is not defined with bool data type. Please set order to 0 or explicitely cast input image to another data type. Starting from version 0.19 a ValueError will be raised instead of this warning. order = _validate_interpolation_order(image.dtype, order) D:\env\python3.7.0\lib\site-packages\skimage\transform_warps.py:830: FutureWarning: Input image dtype is bool. Interpolation is not defined with bool data type. Please set order to 0 or explicitely cast input image to another data type. Starting from version 0.19 a ValueError will be raised instead of this warning. order = _validate_interpolation_order(image.dtype, order) 2023-09-27 00:13:25.528767: E tensorflow/stream_executor/stream.cc:334] Error recording event in stream: Error recording CUDA event: CUDA_ERROR_UNKNOWN: unknown error; not marking stream as bad, as the Event object may be at fault. Monitor for further errors. 2023-09-27 00:13:25.528894: E tensorflow/stream_executor/cuda/cuda_event.cc:29] Error polling for event status: failed to query event: CUDA_ERROR_UNKNOWN: unknown error 2023-09-27 00:13:25.528950: F tensorflow/core/common_runtime/device/device_event_mgr.cc:221] Unexpected Event status: 1
from tensorflow.python.framework.ops import disable_eager_execution
disable_eager_execution()
it helps me
are u using google colab?
On Tue, Oct 10, 2023 at 11:53 AM mikl20022002 @.***> wrote:
from tensorflow.python.framework.ops import disable_eager_execution disable_eager_execution()
it helps me
— Reply to this email directly, view it on GitHub https://github.com/matterport/Mask_RCNN/issues/2458#issuecomment-1756049064, or unsubscribe https://github.com/notifications/unsubscribe-auth/A667UZE5EC4T24FWBV3UL3LX6WKSVAVCNFSM4VVM3DA2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCNZVGYYDIOJQGY2A . You are receiving this because you commented.Message ID: @.***>
are u using google colab?
yes
I got this error when I try to run this command:
This happens in
mrcnn/model.py:1875