facebookresearch / detectron2

Detectron2 is a platform for object detection, segmentation and other visual recognition tasks.
https://detectron2.readthedocs.io/en/latest/
Apache License 2.0
30.45k stars 7.47k forks source link

Denspose IUV map - why is there no provision of the IUV colourmap which was there in densepose? Please, give ideas on how to recreate those maps based on the iuv array obtained from results.pkl #1751

Open mithunlal opened 4 years ago

mithunlal commented 4 years ago

🚀 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.

jaymefosa commented 3 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)))

image

jaymefosa commented 3 years ago

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

Tangcj1226 commented 3 years ago

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.

jaymefosa commented 3 years ago

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

Tangcj1226 commented 3 years ago

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

Tangcj1226 commented 3 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)))

image

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