How to extract the foreground of pedestrian?

Hi everyone,

I want to extract the foreground of the pedestrian and regenerate the mask according to the extracted foreground object? In other words, remove the background of the pedestrian, and from that extracted foreground generate the new mask.
End result should look similar to this image (the example is not perfect but just to get the idea)
from this extracted image there will be a new mask.

Thank you in advance

@alnakh01 if you are working with nuImages, there are both bounding boxes and masks provided for pedestrians which will enable you to achieve what you want easily. Do check out the nuImages tutorial here: