1.0.0 • Published 2 years ago

ai.natml.vision.ultraface v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

UltraFace

Ultra-light Fast Generic Face Detector for high performance face detection.

Installing UltraFace

Add the following items to your Unity project's Packages/manifest.json:

{
  "scopedRegistries": [
    {
      "name": "NatML",
      "url": "https://registry.npmjs.com",
      "scopes": ["ai.natml"]
    }
  ],
  "dependencies": {
    "ai.natml.vision.ultraface": "1.0.0"
  }
}

Detecting Faces in an Image

First, create the UltraFace predictor:

// Fetch the model data from NatML Hub
var modelData = await MLModelData.FromHub("@natsuite/ultraface");
// Deserialize the model
var model = modelData.Deserialize();
// Create the UltraFace predictor
var predictor = new UltraFacePredictor(model);

Then detect faces in the image:

// Create image feature
Texture2D image = ...;
var imageFeature = new MLImageFeature(image); // This also accepts a `Color32[]` or `byte[]`
(imageFeature.mean, imageFeature.std) = modelData.normalization;
imageFeature.aspectMode = modelData.aspectMode;
// Detect faces
Rect[] faces = predictor.Predict(imageFeature);

Requirements

  • Unity 2021.2+

Quick Tips

Thank you very much!