Open wangtianlong1994 opened 4 years ago
I'll need to look into this further as something deeper is broken in the forward pass. For your specific error, you can replace:
int(mdef["from"])
with:
int(mdef["from"][0])
However, doing so will bring to light the other issues which I need to look into.
我需要进一步研究这一点,因为前向传递中有更深层的问题。对于您的特定错误,您可以替换:
int(mdef [ “ from” ])
与:
int(mdef [ “ from” ] [ 0 ])
但是,这样做会发现我需要研究的其他问题。
I'll need to look into this further as something deeper is broken in the forward pass. For your specific error, you can replace:
int(mdef["from"])
with:
int(mdef["from"][0])
However, doing so will bring to light the other issues which I need to look into.
YES,When I do what you say, I will still display the type error
x = x + layer_outputs[int(mdef["from"][0])] TypeError: unsupported operand type(s) for +: 'Tensor' and 'list'
Looking forward to your solution
Ok
So on going through the code, Line #95 in gradcam.py should just be layer_outputs.append(x)
This seems to work for me after taking into account the fix mentioned above.
Now i'm running into the following error in misc_functions.py on the line:
heatmap_on_image = Image.alpha_composite(heatmap_on_image, heatmap)
saying images donot match.
Trying to fix this but please let me know if you think the above fix is good enough?
We are also trying this as well.
We were able to solve the issue @praneet195 has by adding the following line after line 91 in misc_functions.py.
https://github.com/pifalken/YOLOv3-GradCAM/blob/6a66a9eb469e43c0d42c7d1ce84eea9c16cff3da/gradcam/misc_functions.py#L91
heatmap_on_image = heatmap_on_image.resize(heatmap.size)
This is at least a temporary fix.
image 1/1 data/samples/Jujube_4501.bmp: Model Summary: 222 layers, 6.1556e+07 parameters, 6.1556e+07 gradients Traceback (most recent call last): File "/home/zxzn/YOLOv3-GradCAM/gradcam/gradcam.py", line 178, in <module> cam = grad_cam.generate_cam(prep_img, target_class) File "/home/zxzn/YOLOv3-GradCAM/gradcam/gradcam.py", line 127, in generate_cam conv_output, model_output = self.extractor.forward_pass(input_image) File "/home/zxzn/YOLOv3-GradCAM/gradcam/gradcam.py", line 106, in forward_pass conv_output, x = self.forward_pass_on_convolutions(x) File "/home/zxzn/YOLOv3-GradCAM/gradcam/gradcam.py", line 91, in forward_pass_on_convolutions x = x + layer_outputs[int(mdef["from"])] TypeError: int() argument must be a string, a bytes-like object or a number, not 'list' Process finished with exit code 1
这是为什么?我使用了由yolov3 of Ultralytics训练的模型和相应的CFG,但无法正常工作。此外,我还从utils文件夹ultralytics models.py的yolov3文件中删除了该文件
这是我的目录结构
(cam) zxzn@zxzn:~/YOLOv3-GradCAM/gradcam$ ls cfg data detect.py gradcam.py misc_functions.py models.py __pycache__ test.py train.py utils weights
谢谢您的帮助@pifalken
你好,我也遇到了这个问题,请问您解决了吗?
好的, 所以在遍历代码时,gradcam.py中的第95行应该只是layer_outputs.append(x)。 考虑到上述修复后,这似乎对我有用。 现在,我在网上的misc_functions.py中遇到以下错误:
heatmap_on_image = Image.alpha_composite(heatmap_on_image, heatmap)
说图像不匹配。 尝试解决此问题,但是如果您认为上述修复足够好,请告诉我。 excause me,How do you fix this bug? x = x + layer_outputs[int(mdef["from"])] TypeError: int() argument must be a string, a bytes-like object or a number, not 'list' please help me。looking forward to your reply。
请问这个问题解决了吗????
Why is that? I used the model trained by yolov3 of ultralytics and the corresponding CFG, but it couldn't work normally. In addition, I also took it out of the yolov3 file of ultralytics models.py , utils folder
This is my directory structure
Thank you for your help @pifalken