Open semihcanturk opened 2 years ago
Hi @semihcanturk , Any progress on this issue so far?
I ran into the same issue, but in my case, I simply converted the RGB format to the BGR format and it worked.
@mahendra-gehlot unfortunately I haven't dug deep into the code to figure out what's the underlying issue, but have noticed something interesting. It seems the heatmaps are correct for yolov5s
, but inverted for yolov5n/m/l
. Furthermore, this exclusively affects EigenCAM, ScoreCAM does not suffer from this for any model I've tried. Here are the outputs for n/s/m + ScoreCAM (n
) for for example:
YOLOv5n | YOLOv5s | YOLOv5m | YOLOv5n (ScoreCAM) |
---|---|---|---|
This also relates with @syncsyncsync 's solution, which doesn't really explain why it works for yolov5s
and ScoreCAM which uses the same image load/save pipeline. I have no intuition yet into why this is happening, but it may prove a good starting point for debugging (for which I may not find sufficient time in the near future I'm afraid).
Hi @jacobgil , I'm working on applying Score-CAM on YOLOv5 by implementing the
YOLOBoxScoreTarget
class (so this issue is closely related with #242). There are several issues I want to iron out before making a PR (e.g. YOLOv5 returns parseableDetection
objects only when the input is not a Torch tensor - see https://github.com/ultralytics/yolov5/issues/6726 - and my workaround is ad-hoc atm), but in my current implementation I find that the resulting heatmaps are inverted, e.g.:Outputs for dog & cat example, unnormalized (L)/normalized (R):
Also observed similar trends with other images like the 5-dogs example. My
YOLOBoxScoreTarget
is as follows, it is essentially identical to FasterRCNNBoxScoreTarget, except it leveragesparse_detections
from the YOLOv5 notebook:I also slightly altered
get_cam_weights
in score_cam.py to make it play nice with numpy inputs instead of torch tensors.To me the implementations seem correct, and therefore I am not able to address why the resulting heatmaps seem inverted. Any ideas? I'd be happy to make a branch with a reproducible example to debug and potentially extend it to a PR. Please let me know.