google-ai-edge / mediapipe

Cross-platform, customizable ML solutions for live and streaming media.
https://ai.google.dev/edge/mediapipe
Apache License 2.0
27.41k stars 5.15k forks source link

Head segmentation in real time? #3503

Open chris-hndz opened 2 years ago

chris-hndz commented 2 years ago

Hi, I am looking for a solution to achieve head segmentation (hair with face segmentation) in real time on a webcam video. What do you recommend to achieve this with mediapipe? What segmentation or mediapipe tracking methods would be useful to achieve this?

HeadSegmentation

Thanks in advance!

brucechou1983 commented 2 years ago

I don't think you could achieve this by just using MediaPipe public models. We've done something similar in my team. We basically train our own model and serve it by MediaPipe.

LGuilhermeRodrigues commented 2 years ago

I would try Selfie Segmentation to remove the background and then Face Mesh to cut the neck

sureshdagooglecom commented 2 years ago

Hi @chris-hndz , These models are not part of MediaPipe solutions currently and this is a feature request.

chris-hndz commented 2 years ago

Thanks for the responses and ideas. I understand this is more of an improvement proposal for Mediapipe.

kuaashish commented 1 year ago

@chris-hndz,

Image Segmenter should be able to do this with the right model. You should try https://storage.googleapis.com/mediapipe-models/image_segmenter/deeplab_v3/float32/1/deeplab_v3.tflite with MediaPipe tasks. Thank you

chris-hndz commented 1 year ago

@kuaashish Thanks for your idea.

We did some tests with the Image Segmentation online demo with the Multi-class selfie segmentation model and we obtained reasonably good results for the segmentation mask of the face and hair. Maybe if we put both masks together we can get the head segmentation mask. But it still has a notorious delay.

headSegmMediaPipe

And when we tested the Face Landmark Detection online demo we got this:

GridRender

Here we see that the face landmarks limit well the lower part of the head.

Is there any way to merge the face and hair segmentation masks, and considering also the cutting the lower part of the face mask according to the face landmarks of the lower part of the face?

Thank you for your answer!

kuaashish commented 1 year ago

@chris-hndz,

You can use Multi-class selfie segmentation model and combine mask 1 (hair) and 3 (face-skin) as guided below:

https://developers.google.com/mediapipe/solutions/vision/image_segmenter#multiclass-model

However, If you will be able to achieve the full head model that can be instructions to other users. Thank you

chris-hndz commented 1 year ago

@kuaashish

Thank you very much for your reply, and advice for combining hair and face-skin mask.

Is there any way to cut the lower part of the face mask according to the face landmarks of the lower part of the face?

Thank you in advance!

kuaashish commented 1 year ago

@chris-hndz,

There is no off-the-shelf solution to this requirement currently. Thank you

github-actions[bot] commented 1 year ago

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

chris-hndz commented 1 year ago

Thanks @kuaashish for your reply.

I understand that there is no off-the-shelf solution to this requirement. Could you perhaps give some guidance or an idea of what would be the way to achieve this please?

Thank you in advance!