Some problems in tool.py
Closed this issue · 5 comments
I don't know how to use the function‘visualize’ in the tool.py as follows:
def visualize(images, cams, e):
#images (batchsize, h, w, 3)
#cams (batchsize, 1, h, w)
images = images.cpu().numpy()
cams = cams.detach().cpu().numpy()
for i in range(images.shape[0]):
if i % 2 == 0:
cor = 'cor'
else:
cor = 'not'
cam = cams[i, 0]
image = images[i]
#recover image to 0-1
image = image * np.array([0.229, 0.224, 0.225]) + np.array([0.485, 0.456, 0.406])
image = np.clip(image, 0, 1)
#generate heatmap
cam = cam * 255
cam = cv2.applyColorMap(cam.astype(np.uint8), cv2.COLORMAP_JET)
cam = cam[:, :, ::-1] / 255
plt.imsave('vis/img'+str(e)+''+str(i)+cor+'.jpg', 0.5cam+0.5image)
I don't see the function called in tool.py ,and I'm so confused ,I will truly appreciate it if you can explain it for me!
In the provided code, we didn’t visualize the results. When you need to visualize some sample, you can call this function in your own code.
The boxes are generated by pretrained detection model. Please read Section 4.1, 'Bounding box annotation' of the paper for details.