Open jiqibuaixuexi opened 1 month ago
是用的哪个示例代码?
用的这个示例代码
请尝试以下方法:
from paddle.vision.models import resnet50
paddle_model = resnet50(pretrained=True)
paddle_model.to("cpu") # add this line
检查一下paddle是否安装正确,是否能正常跑一个图像预测。
如果还是不行,请提供一下paddle的版本号。(我这边使用 '2.5.2' 和 cpu 版本是能跑通的。)
(optional) Briefly introduce yourself.
---我按照gradcam的example代码运行如下
随后,出现了报错
🐛 Bug
AxisError Traceback (most recent call last) Cell In[6], line 1 ----> 1 heatmap = gradcam.interpret( 2 img_path, 3 'layer4.2.conv3', 4 label=None, 5 visual=True, 6 save_path=None)
File d:\Anaconda\envs\pyside_app\lib\site-packages\interpretdl\interpreter\gradient_cam.py:101, in GradCAMInterpreter.interpret(self, inputs, target_layer_name, label, resize_to, crop_to, visual, save_path) 96 g = gradients 98 # print(f.shape, g.shape) # [bsz, channels, w, h] 99 100 # the core algorithm --> 101 cam_weights = np.mean(g, (2, 3), keepdims=True) 102 heatmap = cam_weights * f 103 heatmap = heatmap.mean(1)
File <__array_function__ internals>:200, in mean(*args, **kwargs)
File d:\Anaconda\envs\pyside_app\lib\site-packages\numpy\core\fromnumeric.py:3464, in mean(a, axis, dtype, out, keepdims, where) 3461 else: 3462 return mean(axis=axis, dtype=dtype, out=out, **kwargs) -> 3464 return _methods._mean(a, axis=axis, dtype=dtype, ... 81 # axis and full sum is more excessive than needed. 82 83 # guarded to protect circular imports
AxisError: axis 2 is out of bounds for array of dimension 0 Briefly describe the bug.
To Reproduce
Steps to reproduce the behavior:
1. 2. 3.
If you were running a command, please post the exact command that you were running.
If you have a code sample, error messages, stack traces, please provide it here as well.
(optional) Enviroment
If you know well the environment of your machine, please put the information below: