/visual-for-mmdetection

a simple code for visualize the heat map from backbone and fpn while test with mmdetection

Primary LanguagePython

visual-for-mmdetection

a simple code for visualize the heat map from backbone and fpn while test with mmdetection

if you use two-stage detector, such as faster rcnn,please change the codes :

1. mmdet/models/detectors/two_stage.py

def extract_feat(self, img):
    x_backbone = self.backbone(img)
    if self.with_neck:
        x_fpn = self.neck(x_backbone)
    return x_backbone,x_fpn

and:

def simple_test(self, img, img_metas, proposals=None, rescale=False):
    """Test without augmentation."""
    assert self.with_bbox, 'Bbox head must be implemented.'

    x_backbone,x_fpn = self.extract_feat(img)

    if proposals is None:
        proposal_list = self.simple_test_rpn(x_fpn, img_metas)
    else:
        proposal_list = proposals

    return self.roi_head.simple_test(
        x_fpn, proposal_list, img_metas, rescale=rescale),x_backbone,x_fpn

2.mmdet/apis/inference.py

def inference_detector(model, img):
.......
        # forward the model
    with torch.no_grad():
        result,x_backbone,x_fpn= model(return_loss=False, rescale=True, **data)
    return result,x_backbone,x_fpn

if you use other detectors, it is easy to change it like this

useage:

1:change the config,checkpoint,img
2: run the code

I refer to some codes , this code is rough and not rigorous