matterport / Mask_RCNN

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

showing mAP in the same time as training #1139

Open javierfs opened 5 years ago

javierfs commented 5 years ago

I am trying to show the mAP by using utils.compute_ap() function. I am trying to understand what are the graphs that are shown with TensorBoard: rpn_class_loss, rpn_bbox_loss, class_loss, bbox_loss, mask_loss.

I want to show the mAP after each epoch as the previous losses. However, I am stuck:

In models.py:

# Losses
            rpn_class_loss = KL.Lambda(lambda x: rpn_class_loss_graph(*x), name="rpn_class_loss")(
                [input_rpn_match, rpn_class_logits])
            rpn_bbox_loss = KL.Lambda(lambda x: rpn_bbox_loss_graph(config, *x), name="rpn_bbox_loss")(
                [input_rpn_bbox, input_rpn_match, rpn_bbox])
            class_loss = KL.Lambda(lambda x: mrcnn_class_loss_graph(*x), name="mrcnn_class_loss")(
                [target_class_ids, mrcnn_class_logits, active_class_ids])
            bbox_loss = KL.Lambda(lambda x: mrcnn_bbox_loss_graph(*x), name="mrcnn_bbox_loss")(
                [target_bbox, target_class_ids, mrcnn_bbox])
            mask_loss = KL.Lambda(lambda x: mrcnn_mask_loss_graph(*x), name="mrcnn_mask_loss")(
                [target_mask, target_class_ids, mrcnn_mask])

            mAP, precisions, recalls, overlaps = utils.compute_ap(input_gt_boxes, input_gt_class_ids, input_gt_masks,mrcnn_bbox,tf.argmax(rpn_class_logits, axis=2), ..   )

I am not sure about what is pred_scores. I believe is detections[...,5] (See Below)

# Detections
            # output is [batch, num_detections, (y1, x1, y2, x2, class_id, score)] in
            # normalized coordinates
            detections = DetectionLayer(config, name="mrcnn_detection")(
                [rpn_rois, mrcnn_class, mrcnn_bbox, input_image_meta])

However, mrcnn_mask, mrcnn_bbox, etc. are not drawn from Detection DetectionLayer() but from build_fpn_mask_graph(). I am not sure if is possible to show the mAP during training... Any ideas?

koukouzasg commented 5 years ago

@javierfs Hello, i want to do the same thing. When i train my model, after each epoch the losses and val_losses are printed but i also want to show the mAP so i can have a better insight on the quality of my model. Have found a way if it's possible, and if yes can you provide me with some tips?

javierfs commented 5 years ago

Hi @koukouzasg, I have made it! Please, check #1024