ai.natml.vision.hair-matte-net
v1.0.0
Published
Hair matte segmentation in Unity Engine.
Downloads
28
Maintainers
Readme
Hair Matte Net
Hair matte segmentation. This predictor implements HairMatteNet. This package requires NatML.
Segmenting Hair in an Image
First, create the predictor:
// Fetch model data from NatML Hub
var modelData = await MLModelData.FromHub("@natsuite/hair-matte-net");
// Deserialize the model
var model = modelData.Deserialize();
// Create the hair segmentation predictor
var predictor = new HairMatteNetPredictor(model);
Then segment hair in an image:
Texture2D image = ...; // Can also be an `MLImageFeature`
// Segment the hair in the image
HairMatteNetPredictor.Matte matte = predictor.Predict(image);
Finally, render the segmentation map to a RenderTexture
:
// Create a `RenderTexture`
var hairMask = new RenderTexture(image.width, image.height, 0);
// Render the segmentation map into the render texture
matte.Render(hairMask);
References
- https://arxiv.org/pdf/1712.07168.pdf
- https://github.com/wonbeomjang/mobile-hair-segmentation-pytorch
Requirements
- Unity 2020.3+
- NatML 1.0.16+
Quick Tips
- Discover more ML models on NatML Hub.
- See the NatML documentation.
- Join the NatML community on Discord.
- Discuss NatML on Unity Forums.
- Contact us at [email protected].
Thank you very much!