Open CHENSY-SIYU opened 2 years ago
本人萌新,同样遇到了'tuple' object has no attribute 'cpu'问题,想请教下怎么解决的
Write a wrapper around the model such that only the prediction of the model is returned:
class ModelInferenceGradCam(torch.nn.Module):
def __init__(self, model):
super().__init__()
self.model = model
def forward(self, x):
return self.model(x)[0]
Use this wrapper for GradCam instead of the raw model.
本人萌新,同样遇到了'tuple' object has no attribute 'cpu'问题,想请教下怎么解决的
请问您解决了吗,我也有这个问题
嗯,使用DAN可视化的时候把网络的输出改为单输出即可
------------------ 原始邮件 ------------------ 发件人: "yaoing/DAN" @.>; 发送时间: 2023年5月28日(星期天) 中午1:07 @.>; @.**@.>; 主题: Re: [yaoing/DAN] Question in demo.py and run_grad_cam.py (Issue #27)
本人萌新,同样遇到了'tuple' object has no attribute 'cpu'问题,想请教下怎么解决的
请问您解决了吗,我也有这个问题
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
嗯,使用DAN可视化的时候把网络的输出改为单输出即可 … ------------------ 原始邮件 ------------------ 发件人: "yaoing/DAN" @.>; 发送时间: 2023年5月28日(星期天) 中午1:07 @.>; @.**@.>; 主题: Re: [yaoing/DAN] Question in demo.py and run_grad_cam.py (Issue #27) 本人萌新,同样遇到了'tuple' object has no attribute 'cpu'问题,想请教下怎么解决的 请问您解决了吗,我也有这个问题 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
您好,我是萌新不好意思打扰了, 单输出是指只保留out,x和heads中的一个吧,保留哪个呢,谢谢
嗯,使用DAN可视化的时候把网络的输出改为单输出即可 … ------------------ 原始邮件 ------------------ 发件人: "yaoing/DAN" @.>; 发送时间: 2023年5月28日(星期天) 中午1:07 @.>; @.**@.>; 主题: Re: [yaoing/DAN] Question in demo.py and run_grad_cam.py (Issue #27) 本人萌新,同样遇到了'tuple' object has no attribute 'cpu'问题,想请教下怎么解决的 请问您解决了吗,我也有这个问题 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***> 可以提供一下您修改好的版本吗,我的邮箱是:484330880@qq.com 十分感谢您!
印象中是保留out。因为grad-cam原理是要通过单个输出获得反向传播的梯度值,希望可以帮到你。
------------------ 原始邮件 ------------------ 发件人: "yaoing/DAN" @.>; 发送时间: 2023年5月28日(星期天) 下午2:59 @.>; @.**@.>; 主题: Re: [yaoing/DAN] Question in demo.py and run_grad_cam.py (Issue #27)
嗯,使用DAN可视化的时候把网络的输出改为单输出即可 … ------------------ 原始邮件 ------------------ 发件人: "yaoing/DAN" @.>; 发送时间: 2023年5月28日(星期天) 中午1:07 @.>; @.@.>; 主题: Re: [yaoing/DAN] Question in demo.py and run_grad_cam.py (Issue #27) 本人萌新,同样遇到了'tuple' object has no attribute 'cpu'问题,想请教下怎么解决的 请问您解决了吗,我也有这个问题 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
您好,我是萌新不好意思打扰了,
单输出是指只保留out,x和heads中的一个吧,保留哪个呢,谢谢
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
印象中是保留out。因为grad-cam原理是要通过单个输出获得反向传播的梯度值,希望可以帮到你。 … ------------------ 原始邮件 ------------------ 发件人: "yaoing/DAN" @.>; 发送时间: 2023年5月28日(星期天) 下午2:59 @.>; @.**@.>; 主题: Re: [yaoing/DAN] Question in demo.py and run_grad_cam.py (Issue #27) 嗯,使用DAN可视化的时候把网络的输出改为单输出即可 … ------------------ 原始邮件 ------------------ 发件人: "yaoing/DAN" @.>; 发送时间: 2023年5月28日(星期天) 中午1:07 @.>; @.@.>; 主题: Re: [yaoing/DAN] Question in demo.py and run_grad_cam.py (Issue #27) 本人萌新,同样遇到了'tuple' object has no attribute 'cpu'问题,想请教下怎么解决的 请问您解决了吗,我也有这个问题 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.> 您好,我是萌新不好意思打扰了, 单输出是指只保留out,x和heads中的一个吧,保留哪个呢,谢谢 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.>
好的,感谢你!
question 1: python run_grad_cam.py Traceback (most recent call last): File "run_grad_cam.py", line 94, in
eigen_smooth=False)
File "/home/a123/anaconda3/envs/fer/lib/python3.7/site-packages/pytorch_grad_cam/base_cam.py", line 130, in call
target_category, eigen_smooth)
File "/home/a123/anaconda3/envs/fer/lib/python3.7/site-packages/pytorch_grad_cam/base_cam.py", line 66, in forward
target_category = np.argmax(output.cpu().data.numpy(), axis=-1)
AttributeError: 'tuple' object has no attribute 'cpu'
Need to replace several variables manually? What are they? question 2: when I test an image ,I find that the emotion label can't match the category .What's the problem?