File tree 1 file changed +8
-6
lines changed
1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 7
7
入口类
8
8
9
9
"""
10
- import re
10
+ import argparse
11
11
import os
12
+ import re
13
+
14
+ import cv2
12
15
import numpy as np
13
16
import torch
17
+ from skimage import io
14
18
from torch import nn
15
19
from torchvision import models
16
- import argparse
17
- from skimage import io
18
- import cv2
20
+
19
21
from interpretability .grad_cam import GradCAM , GradCamPlusPlus
20
22
from interpretability .guided_back_propagation import GuidedBackPropagation
21
23
@@ -105,7 +107,7 @@ def gen_cam(image, mask):
105
107
106
108
# 合并heatmap到原始图像
107
109
cam = heatmap + np .float32 (image )
108
- return norm_image (cam ), heatmap
110
+ return norm_image (cam ), ( heatmap * 255 ). astype ( np . uint8 )
109
111
110
112
111
113
def norm_image (image ):
@@ -166,7 +168,7 @@ def main(args):
166
168
grad = gbp (inputs )
167
169
168
170
gb = gen_gb (grad )
169
- image_dict ['gb' ] = gb
171
+ image_dict ['gb' ] = norm_image ( gb )
170
172
# 生成Guided Grad-CAM
171
173
cam_gb = gb * mask [..., np .newaxis ]
172
174
image_dict ['cam_gb' ] = norm_image (cam_gb )
You can’t perform that action at this time.
0 commit comments