Open mithunlal opened 4 years ago
seems this does the trick- let me know if this works for you:
sys.path.append(DenseposePath)
with open(dp_output, 'rb') as f:
data = pickle.load(f)
i = data[0]['pred_densepose'][0].labels.cpu().numpy()
uv = data[0]['pred_densepose'][0].uv.cpu().numpy()
iuv = np.stack((uv[1,:,:], uv[0,:,:], i * 0,))
plt.imshow(np.transpose(iuv, (1,2,0)))
slight adjustment:
i = data[0]['pred_densepose'][0].labels.cpu().numpy()
uv = data[0]['pred_densepose'][0].uv.cpu().numpy() * 255
iuv = np.stack((uv[1,:,:], uv[0,:,:], i))
iuv = np.transpose(iuv, (1,2,0))
plt.imshow(iuv / 255)
also make sure to save as .png
slight adjustment:
i = data[0]['pred_densepose'][0].labels.cpu().numpy() uv = data[0]['pred_densepose'][0].uv.cpu().numpy() * 255 iuv = np.stack((uv[1,:,:], uv[0,:,:], i)) iuv = np.transpose(iuv, (1,2,0)) plt.imshow(iuv / 255)
also make sure to save as .png
Is there a way to get the iuv_arr in the shape of the original image instead of the shape of the bounding box?I figured out how to get iuv map like you, but it's different from original shape. thanks.
Yep, I don't have the code open in front of me but one of the keys in data is an [x, y, w, h] type array where the first two values are x1 and y1 for the upper left corner of detection, in the original image
Yep, I don't have the code open in front of me but one of the keys in data is an [x, y, w, h] type array where the first two values are x1 and y1 for the upper left corner of detection, in the original image
thanks for your suggestion,i'll try
seems this does the trick- let me know if this works for you:
sys.path.append(DenseposePath) with open(dp_output, 'rb') as f: data = pickle.load(f) i = data[0]['pred_densepose'][0].labels.cpu().numpy() uv = data[0]['pred_densepose'][0].uv.cpu().numpy() iuv = np.stack((uv[1,:,:], uv[0,:,:], i * 0,)) plt.imshow(np.transpose(iuv, (1,2,0)))
supplement you can get image in original shape by code: box = data[0]["pred_boxes_XYXY"][0] box[2]=box[2]-box[0] box[3]=box[3]-box[1] x,y,w,h=[int(v) for v in box] bg=np.zeros((512,512,3)) bg[y:y+h,x:x+w,:]=iuv plt.imshow(bg/255)
more details in densepose.vis.base and densepose.vis.extracter
🚀 Feature
It would be hepful if you could share the implementation details of generation of 3 channel IUV.png using the IUV array from results.pkl. Needed to know the transformations applied to obtain those from the IUV mapping.