matterport / Mask_RCNN

Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow
Other
24.43k stars 11.67k forks source link

Focal loss #1829

Open rcx986635 opened 4 years ago

rcx986635 commented 4 years ago

if appling focal_loss to rpn_class ,mrcnn_class ,mrcnn_mask , the performance will be better ?

Amrimn commented 4 years ago

@rcx986635 is it better?

rcx986635 commented 4 years ago

actually not better than before.

charlie6echo commented 3 years ago

Apply if your dataset has imbalance, you have to apply multi-class sparse focal loss in all three. checkout here Multi-class Focal loss on mask RCNN.

avinash-218 commented 1 year ago

Apply if your dataset has imbalance, you have to apply multi-class sparse focal loss in all three. checkout here Multi-class Focal loss on mask RCNN.

I am getting this error in 'mrcnn_class_loss_graph' when uncommented the focal loss in the code. Could you please help me with this?

Traceback (most recent call last): File "final.py", line 543, in train(model) File "final.py", line 356, in train model.train(dataset_train, dataset_val, File "/home/ubuntu/Fur_Seg/Mask-RCNN-TF2.7.0-keras2.7.0/mrcnn/model.py", line 2386, in train self.keras_model.fit( File "/home/ubuntu/tf2.7/lib/python3.8/site-packages/keras/engine/training_v1.py", line 777, in fit return func.fit( File "/home/ubuntu/tf2.7/lib/python3.8/site-packages/keras/engine/training_generator_v1.py", line 570, in fit return fit_generator( File "/home/ubuntu/tf2.7/lib/python3.8/site-packages/wandb/integration/keras/keras.py", line 166, in new_generator return old_generator(*args, kwargs) File "/home/ubuntu/tf2.7/lib/python3.8/site-packages/wandb/integration/keras/keras.py", line 166, in new_generator return old_generator(*args, *kwargs) File "/home/ubuntu/tf2.7/lib/python3.8/site-packages/wandb/integration/keras/keras.py", line 166, in new_generator return old_generator(args, kwargs) File "/home/ubuntu/tf2.7/lib/python3.8/site-packages/keras/engine/training_generator_v1.py", line 252, in model_iteration batch_outs = batch_function(batch_data) File "/home/ubuntu/tf2.7/lib/python3.8/site-packages/keras/engine/training_v1.py", line 1076, in train_on_batch outputs = self.train_function(ins) # pylint: disable=not-callable File "/home/ubuntu/tf2.7/lib/python3.8/site-packages/keras/backend.py", line 4186, in call fetched = self._callable_fn(array_vals, File "/home/ubuntu/tf2.7/lib/python3.8/site-packages/tensorflow/python/client/session.py", line 1483, in call ret = tf_session.TF_SessionRunCallable(self._session._session, tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found. (0) INVALID_ARGUMENT: required broadcastable shapes [[{{node mrcnn_class_loss/mul}}]] [[loss/AddN/_3329]] (1) INVALID_ARGUMENT: required broadcastable shapes [[{{node mrcnn_class_loss/mul}}]] 0 successful operations. 0 derived errors ignored.