YOLO-V5 GRADCAM
I constantly desired to know to which part of an object the object-detection models pay more attention. So I searched for it, but I didn't find any for Yolov5. Here is my implementation of Grad-cam for YOLO-v5. To load the model I used the yolov5's main codes, and for computing GradCam I used the codes from the gradcam_plus_plus-pytorch repository. Please follow my GitHub account and star
Installation
pip install -r requirements.txt
Infer
python main.py --model-path yolov5s.pt --img-path images/cat-dog.jpg --output-dir outputs
NOTE: If you don't have any weights and just want to test, don't change the model-path argument. The yolov5s model will be automatically downloaded thanks to the download function from yolov5.
NOTE: For more input arguments, check out the main.py or run the following command:
python main.py -h
Examples
Note
I checked the code, but I couldn't find an explanation for why the truck's heatmap does not show anything. Please inform me or create a pull request if you find the reason.
TO Do
- Add GradCam++
- Add ScoreCam
- Add the functionality to the deep_utils library
References
- https://github.com/1Konny/gradcam_plus_plus-pytorch
- https://github.com/ultralytics/yolov5
- https://github.com/pooya-mohammadi/deep_utils
Citation
Please cite yolov5-gradcam if it helps your research. You can use the following BibTeX entry:
@misc{deep_utils,
title = {yolov5-gradcam},
author = {Mohammadi Kazaj, Pooya},
howpublished = {\url{github.com/pooya-mohammadi/yolov5-gradcam}},
year = {2021}
}