soumyaiitkgp / Custom_MaskRCNN

Custom Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow
Other
71 stars 49 forks source link

Issue while trying to train model #9

Open SamvdVoort opened 3 years ago

SamvdVoort commented 3 years ago

So I have followed the Medium article and am trying to train the model on a custom dataset of floorplans. After working around some issues I found I am finally ready to train.

However, now I run into a new problem which I can not seem to fix myself. When trying to train on a custom dataset, I get the following error:

Traceback (most recent call last): File "custom.py", line 391, in <module> train(model) File "custom.py", line 222, in train layers='heads') File "C:\...\Custom_MaskRCNN-master\mrcnn\model.py", line 2356, in train self.compile(learning_rate, self.config.LEARNING_MOMENTUM) File "C:\...\Custom_MaskRCNN-master\mrcnn\model.py", line 2201, in compile self.keras_model.add_metric(loss, name) AttributeError: 'Model' object has no attribute 'add_metric'

This comes right after the model should start training, stating that it is starting at epoch 0. We are kind of at a loss, as we have been struggling to use this model for a couple of hours now.

If anybody knows a solution that would be very much appreciated.

sadhoss commented 3 years ago

For the next person struggling with this.

This thread on Stackoverflow resolved it for me.

TL;DR:

  1. Use tf version 1.3.0, keras version 2.0.8.
  2. Comment out this line, replace with <self.keras_model.metric_tensors.append(loss)>. This makes the code run.