Training MaskRCNN on custom data issue

Tags: , ,

I am trying to train Mask RCNN on a custom dataset of floorplans. I am following this article on Medium to do this: .

After having some issues with annotation formats and packages I got around to training the model. However, I stumbled upon the following error code:

Traceback (most recent call last):
  File "", line 391, in <module>
  File "", line 222, in train
  File "", line 2356, in train
    self.compile(learning_rate, self.config.LEARNING_MOMENTUM)
  File "", line 2201, in compile
    self.keras_model.add_metric(loss, name)
AttributeError: 'Model' object has no attribute 'add_metric'

I could not find anything about this error and was hoping someone could help out or give me an indication on how to fix this.


As we can see, the requirements file does not specify an exact TF & Keras version but, only a lower limit.


When your env was created, the most recent versions of TensorFlow & Keras would have got installed. The ‘add_metric’ method might be deprecated or moved to another class in the the latest version that got installed, as there have been major version updates to these frameworks. Please note that the author of the repo associated with this article has not been updated it in the last two years. Even the author of the original repo which this repo is based on, has not yet updated it (Original repo: It is very likely that you’re going to face more errors once the current one is solved.

One way to solve this issue would be to downgrade TF and Keras versions (tensorflow to 1.3.0, keras to 2.0.8 may resolve it).

The best course of action would be to port the code using the official conversion tools provided by TensorFlow to convert the TF1.x code to TF2.x or to use a repo in which the code has already been converted.

MaskRCNN Repo with Updated TF and Keras:

Hope that helps! Cheers :)

Source: stackoverflow