gjy3035 / C-3-Framework

An open-source PyTorch code for crowd counting
MIT License
699 stars 200 forks source link

Predicted density map visualization #74

Closed srinadhu closed 4 years ago

srinadhu commented 4 years ago

Hello @gjy3035 ,

Can you please provide density map visualization code as well, I am having some trouble with it?

Thanks and Regards.

dayala1 commented 4 years ago

There is already in test.py:

with torch.no_grad():
            img = Variable(img[None,:,:,:]).cuda()
            pred_map = net.test_forward(img)

pred_map = pred_map.cpu().data.numpy()[0,0,:,:]
pred_map = pred_map/np.max(pred_map+1e-20)

pred_frame = plt.gca()
plt.imshow(pred_map, 'jet')
pred_frame.axes.get_yaxis().set_visible(False)
pred_frame.axes.get_xaxis().set_visible(False)
pred_frame.spines['top'].set_visible(False) 
pred_frame.spines['bottom'].set_visible(False) 
pred_frame.spines['left'].set_visible(False) 
pred_frame.spines['right'].set_visible(False) 
srinadhu commented 4 years ago

I already figured it out in my code but thanks anyway.