| 41 | return img_res.permute(0,3,1,2) |
| 42 | |
| 43 | class ColorMap(): |
| 44 | def __init__(self, basergb=[255,255,0]): |
| 45 | self.basergb = np.array(basergb) |
| 46 | def __call__(self, attnmap): |
| 47 | # attnmap: h, w. np.uint8. |
| 48 | # return: h, w, 4. np.uint8. |
| 49 | assert attnmap.dtype == np.uint8 |
| 50 | h, w = attnmap.shape |
| 51 | res = self.basergb.copy() |
| 52 | res = res[None][None].repeat(h, 0).repeat(w, 1) # h, w, 3 |
| 53 | attn1 = attnmap.copy()[..., None] # h, w, 1 |
| 54 | res = np.concatenate((res, attn1), axis=-1).astype(np.uint8) |
| 55 | return res |
| 56 | |
| 57 | |
| 58 | class COCOVisualizer(): |
nothing calls this directly
no outgoing calls
no test coverage detected