即使我尝试过,我也无法解决这个错误。
https://www.youtube.com/watch?v=GSDbfGsxruA
当我添加 The Mask RCNN 时,我几乎走到了最后一步,但我被困在这里。
错误日志
AttributeError Traceback (most recent call last)
<ipython-input-4-138183a2a830> in <module>
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)
~\**\Mask_RCNN\mrcnn\model.py in __init__(self, mode, config, model_dir)
1838 self.model_dir = model_dir
1839 self.set_log_dir()
-> 1840 self.keras_model = self.build(mode=mode, config=config)
1841
1842 def build(self, mode, config):
~\**\Mask_RCNN\mrcnn\model.py in build(self, mode, config)
2044 # output is [batch, num_detections, (y1, x1, y2, x2, class_id, score)] in
2045 # normalized coordinates
-> 2046 detections = DetectionLayer(config, name="mrcnn_detection")(
2047 [rpn_rois, mrcnn_class, mrcnn_bbox, input_image_meta])
2048
**\anaconda3\lib\site-packages\tensorflow\python\keras\engine\base_layer.py in __call__(self, *args, **kwargs)
949 # >> model = tf.keras.Model(inputs, outputs)
950 if _in_functional_construction_mode(self, inputs, args, kwargs, input_list):
--> 951 return self._functional_construction_call(inputs, args, kwargs,
952 input_list)
953
**\anaconda3\lib\site-packages\tensorflow\python\keras\engine\base_layer.py in _functional_construction_call(self, inputs, args, kwargs, input_list)
1088 layer=self, inputs=inputs, build_graph=True, training=training_value):
1089 # Check input assumptions set after layer building, e.g. input shape.
-> 1090 outputs = self._keras_tensor_symbolic_call(
1091 inputs, input_masks, args, kwargs)
1092
**\anaconda3\lib\site-packages\tensorflow\python\keras\engine\base_layer.py in _keras_tensor_symbolic_call(self, inputs, input_masks, args, kwargs)
820 return nest.map_structure(keras_tensor.KerasTensor, output_signature)
821 else:
--> 822 return self._infer_output_signature(inputs, args, kwargs, input_masks)
823
824 def _infer_output_signature(self, inputs, args, kwargs, input_masks):
**\anaconda3\lib\site-packages\tensorflow\python\keras\engine\base_layer.py in _infer_output_signature(self, inputs, args, kwargs, input_masks)
861 # TODO(kaftan): do we maybe_build here, or have we already done it?
862 self._maybe_build(inputs)
--> 863 outputs = call_fn(inputs, *args, **kwargs)
864
865 self._handle_activity_regularization(inputs, outputs)
**\anaconda3\lib\site-packages\tensorflow\python\autograph\impl\api.py in wrapper(*args, **kwargs)
668 except Exception as e: # pylint:disable=broad-except
669 if hasattr(e, 'ag_error_metadata'):
--> 670 raise e.ag_error_metadata.to_exception(e)
671 else:
672 raise
AttributeError:在用户代码中:
**\Mask_RCNN\mrcnn\model.py:810 call *
detections_batch = utils.batch_slice(
**\Mask_RCNN\mrcnn\utils.py:820 batch_slice *
output_slice = graph_fn(*inputs_slice)
**\Mask_RCNN\mrcnn\model.py:720 refine_detections_graph *
keep = tf.sets.set_intersection(tf.expand_dims(keep, 0),
AttributeError: module 'tensorflow._api.v2.sets' has no attribute 'set_intersection'
model.py按照这里安排。
https://github.com/matterport/Mask_RCNN/issues/1070#issuecomment-740430758