OpenGVLab / InternImage

[CVPR 2023 Highlight] InternImage: Exploring Large-Scale Vision Foundation Models with Deformable Convolutions
https://arxiv.org/abs/2211.05778
MIT License
2.47k stars 231 forks source link

Is there a way to extract the heatmap based on the feature map from image_demo.py? #270

Open jeonga0303 opened 8 months ago

jeonga0303 commented 8 months ago

Is there a way to extract the heatmap based on the feature map from image_demo.py? I want to visualize the generated heatmap by overlapping it on the original image. From this, I think I can find out which areas the model values. Is there a way?

def main(args):
    # build the model from a config file and a checkpoint file
    model = init_detector(args.config, args.checkpoint, device=args.device)
    # test a single image
    result = inference_detector(model, args.img)
    print(result)
    mmcv.mkdir_or_exist(args.out)
    out_file = osp.join(args.out, osp.basename(args.img))
    # show the results
    model.show_result(
        args.img,
        result,
        score_thr=args.score_thr,
        show=False,
        bbox_color=args.palette,
        text_color=(200, 200, 200),
        mask_color=args.palette,
        out_file=out_file
    )
    print(f"Result is save at {out_file}")