【发布时间】:2023-01-30 21:04:15
【问题描述】:
我正在尝试从这里获取 TF2 mask-rcnn:https://github.com/ahmedfgad/Mask-RCNN-TF2 以与 Tensorflow==2.11.0 和 Keras==2.11.0 一起运行。
我无法通过models.py中1873行def build(self, mode, config)函数中KL.Lambda的rekards错误。
确切错误:
Traceback (most recent call last):
File "/mnt/gluster-vol1/Source/d2/./d2.py", line 43, in <module>
d2.train()
File "/mnt/gluster-vol1/Source/d2/autoAnnotate.py", line 387, in train
model = MaskRCNN(mode='training',model_dir='./training_results/',config=config)
File "/mnt/gluster-vol1/Source/d2/mrcnn/model.py", line 1837, in __init__
self.keras_model = self.build(mode=mode, config=config)
File "/mnt/gluster-vol1/Source/d2/mrcnn/model.py", line 1873, in build
gt_boxes = KL.Lambda(lambda x: norm_boxes_graph(x, K.shape(input_image)[1:3]))(input_gt_boxes)
File "/home/user/env/py31/lib/python3.10/site-packages/keras/utils/traceback_utils.py", line 70, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/home/user/env/py31/lib/python3.10/site-packages/tensorflow/python/framework/type_spec.py", line 925, in type_spec_from_value
raise TypeError(f"Could not build a TypeSpec for {value} of "
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 'keras.engine.keras_tensor.KerasTensor'>.
我尝试在KL.Lambda层的函数上使用tf.convert_to_tensor,我在input_gt_boxes层和其他几个地方尝试过,没有任何效果。如果我只构建 KL.Lambda 层,它构建得很好,当它连接到 input_gt_boxes 时,Tensorflow 会出错。
关于如何解决这个问题的任何方向都会很棒。
注意:我不想降级我的 TF 或 Keras 版本,我想让这个 Mask-RCNN 实现与最新版本的 TF 和 Keras 一起工作。
【问题讨论】:
标签: python-3.x tensorflow keras tensorflow2.0