-
-
Notifications
You must be signed in to change notification settings - Fork 16k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grad-Cam for yolov5-5.0 #5863
Comments
@xiaowk5516 hi, Thank you for your work, I would like to ask if you can show ComputeLoss function in your change code |
you can find ComputeLoss in loss.py.(I remove the bbox loss.) |
Yes, I found ComputeLoss, but I encountered another error: |
Excuse me, could you please tell me what should be changed in ComputeLoss,Because the direct call will report an error。There is no hyp parameter |
comment out |
just set the bbox loss to 0. |
sorry,I don't understand what you mean, can you publish the code of your ComputeLoss |
I have only one class.(you can use the origin ComputeLoss and dont change anything)
|
sorry..., I will submit a PR later. |
Thank you. You're right. I'm using version 6.0
…------------------ 原始邮件 ------------------
发件人: ***@***.***>;
发送时间: 2021年12月8日(星期三) 下午4:07
收件人: ***@***.***>;
抄送: ***@***.***>; ***@***.***>;
主题: Re: [ultralytics/yolov5] Grad-Cam for yolov5-5.0 (Issue #5863)
Thank you.But my problem is that when I run detect.py, this code in ComputeLoss is wrong -- (h = model.hyp),because I didn't give this parameter in detect.py. Maybe my version is different from yours. Could you please email me your project code.I would be most grateful. I have been working on this feature for a long time and I am very tired. ------------------ 原始邮件 ------------------ 发件人: "ultralytics/yolov5" @.>; 发送时间: 2021年12月8日(星期三) 下午3:26 @.>; @.@.>; 主题: Re: [ultralytics/yolov5] Grad-Cam for yolov5-5.0 (Issue #5863) I have only one class.(you can use the origin ComputeLoss) Just for yolov5-5.0. lbox *= self.hyp['box'] lobj *= self.hyp['obj'] lcls *= self.hyp['cls'] bs = tobj.shape[0] # batch size # grad_cam = True # if grad_cam: # return lobj * bs, torch.cat((lbox, lobj, lcls)).detach() return (lbox + lobj + lcls) * bs, torch.cat((lbox, lobj, lcls)).detach() — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
sorry..., Ill submit a PR later. you can git clone yolov5-5.0 and any weights for yolov5-5.0. try to add this codes.(yolov5-6.0 has DetectMultiBackend layer, its different from yolov5-5.0, cannot use it directly)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
I'm using version 5.0 and I have the same problem with the man up there: |
|
Thank you very much for your patient guidance.I hope I can help you some day. |
😄 |
Hello, thank you very much for writing this article. I have a question: I implemented it exactly according to your method. Although there were no problems with the above friends, the program said "device = next(model.parameters()).device # get model device " of "loss.py" does not work when executing "compute_loss = ComputeLoss(model)" of "detect.py" , and then an error StopIteration is reported. Do you know how to solve this situation? thank you😫 |
@MrReeed Are you using version 6 ? |
yeah, so, will your version 6 work properly? Neither my version 5 nor version 6 can run successfully😭 |
what`s the type of imgsz? imgsz should be (640, 640) or somethings like this. |
Yes, except for the code you specified changed, the rest of the code is the original default V5 version (v6 was also tried) |
the error message shows that imgsz is int not iterable, how about checking your code? |
@xiaowk5516 model(torch.zeros(1, 3, *imgsz).to(device).type_as(next(model.parameters()))) |
yes, indeed |
I encountered this error what is going on? please help me |
@XiangqingZhang need you add variable 'visualize' in the arguments to the function |
u can set |
Thank you for your prompt reply, but I have another problem? |
@xiaowk5516 你好,首先感谢你的工作,但是对于你的实现我有以下几点疑惑: |
1.#5863 (comment) |
I have a question about whether your visualizations's results focusing on the results of center, even if the center of the target is hollow. |
Hello, I am running on yolov5 version 6.0 and the error message is as follows: Traceback (most recent call last): Is there any solution please? thank you very much! |
你好!邮件我已收到,谢谢~
|
Hi, |
This is related to the name of the saved image file, because every CAM image have the same name, so it is overwritten, you can change the name regulation. |
Hello, may I ask that the representation of my thermal map on all images is the same |
你好!邮件我已收到,谢谢~
|
Have you solved the problem that all diagrams are the same active region? |
you can read this https://github.com/ultralytics/yolov5/issues/5863#issuecomment-1081437756. |
Have you ever testing on edge devices. I have implement it in edge devices and it compute to slow(about 1 minute per image) |
May i please ask how to choose the
May i please ask how to designate the output heat-map of other layers? |
No. I dont test it on any edge devices. do you test the fps of yolov5 with commenting out gradcam. you can output time-comusing of all steps and optimez them. |
which means output the 17, 20 and 23 layer. you can change it according the structure of yolov5. |
|
👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs. Access additional YOLOv5 🚀 resources:
Access additional Ultralytics ⚡ resources:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed! Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐! |
你好!邮件我已收到,谢谢~
|
👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs. Access additional YOLOv5 🚀 resources:
Access additional Ultralytics ⚡ resources:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed! Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐! |
你好!邮件我已收到,谢谢~
|
1 similar comment
你好!邮件我已收到,谢谢~
|
when I tried to run your code I did not get any heatmap |
你好!邮件我已收到,谢谢~
|
你好!邮件我已收到,谢谢~
|
@MrReeed hi there! I'm glad to hear that you received the email. If you have any further questions or need assistance, feel free to ask! |
你好!邮件我已收到,谢谢~
|
@MrReeed 您好!如果您有任何疑问或需要帮助,请随时告诉我!🙂 |
Search before asking
Description
I visualize where the model concerns using grad-cam.
![zidane](https://user-images.githubusercontent.com/59595896/144569829-9d7c4230-a009-454c-a196-d873cbfe010c.jpg)
![17](https://user-images.githubusercontent.com/59595896/144569858-27440f96-f2c4-4ffb-9bb8-0ada5e55600b.jpg)
![20](https://user-images.githubusercontent.com/59595896/144569883-f0785908-462a-475e-b08f-40a4f9e09511.jpg)
![23](https://user-images.githubusercontent.com/59595896/144569893-202abcff-eddb-4299-b9bc-f92e15363be4.jpg)
detection results:
layer 17
layer 20
layer 23
detection results:
![bus](https://user-images.githubusercontent.com/59595896/144570241-31054a93-1be4-470a-afc2-868fa470e6f6.jpg)
![17](https://user-images.githubusercontent.com/59595896/144570230-7486447c-e726-41da-80e0-aa8cdd678b40.jpg)
![20](https://user-images.githubusercontent.com/59595896/144570259-d01d9ab5-2554-40ea-9771-2df8f22893b1.jpg)
![23](https://user-images.githubusercontent.com/59595896/144570275-efe8472a-849c-4629-8aa9-152178b12164.jpg)
layer 17
layer 20
layer 23
my code:
in detect.py
1.add a function
change:
yolov5/detect.py
Lines 59 to 61 in f5b8f7d
to:
change:
yolov5/detect.py
Lines 71 to 72 in f5b8f7d
to
in yolo.py
1.add grad_list and feature_list to store grad and feature
yolov5/models/yolo.py
Lines 66 to 67 in f5b8f7d
2.add hook function in class Model
3.store grad and feature in Model.forward_once()
Use case
a piece of code about Grad-Cam, which can visualize where the model concerns.
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: