Skip to content

Commit

Permalink
Bump to NatML 1.1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
olokobayusuf committed Oct 2, 2023
1 parent 83eb239 commit fee6237
Show file tree
Hide file tree
Showing 24 changed files with 1,962 additions and 594 deletions.
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ Logs/
.gradle/
.vs/

# Function
ProjectSettings/Function.asset

# NatML
Assets/NatML
Assets/NatML.meta
ProjectSettings/NatML.asset
ProjectSettings/NatMLHub.asset

# ARFoundation Remote
ARFoundationRemoteInstaller
ARFoundationRemoteCompanionApp/
# VideoKit
ProjectSettings/VideoKit.asset

# Misc
.DS_Store
606 changes: 305 additions & 301 deletions Assembly-CSharp.csproj

Large diffs are not rendered by default.

25 changes: 8 additions & 17 deletions Assets/BlazePoseDetectorSample.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
* BlazePose Detector
* Copyright (c) 2022 NatML Inc. All Rights Reserved.
* Copyright (c) 2023 NatML Inc. All Rights Reserved.
*/

namespace NatML.Examples {

using UnityEngine;
using NatML.VideoKit;
using NatML.Vision;
using VideoKit;
using Visualizers;

public sealed class BlazePoseDetectorSample : MonoBehaviour {
Expand All @@ -18,36 +18,27 @@ public sealed class BlazePoseDetectorSample : MonoBehaviour {
[Header(@"UI")]
public DetectionVisualizer visualizer;

private MLModelData modelData;
private MLModel model;
private BlazePoseDetector predictor;

private async void Start () {
// Fetch the model data from NatML
modelData = await MLModelData.FromHub("@natml/blazepose-detector");
// Create the model
model = new MLEdgeModel(modelData);
// Create the BlazePose detector
predictor = new BlazePoseDetector(model);
// Create predictor
predictor = await BlazePoseDetector.Create();
// Listen for camera frames
cameraManager.OnFrame.AddListener(OnCameraFrame);
cameraManager.OnCameraFrame.AddListener(OnCameraFrame);
}

private void OnCameraFrame (CameraFrame frame) {
// Create image feature
var feature = frame.feature;
(feature.mean, feature.std) = modelData.normalization;
feature.aspectMode = modelData.aspectMode;
var detections = predictor.Predict(feature);
var detections = predictor.Predict(frame);
// Visualize detections
visualizer.Render(detections);
}

private void OnDisable () {
// Stop listening for camera frames
cameraManager.OnFrame.RemoveListener(OnCameraFrame);
cameraManager.OnCameraFrame.RemoveListener(OnCameraFrame);
// Dispose the model
model?.Dispose();
predictor?.Dispose();
}
}
}
67 changes: 53 additions & 14 deletions Assets/BlazePoseDetectorSample.unity
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994}
m_IndirectSpecularColor: {r: 0.44657838, g: 0.49641234, b: 0.57481676, a: 1}
m_IndirectSpecularColor: {r: 0.44407493, g: 0.49331808, b: 0.5724013, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
Expand Down Expand Up @@ -104,7 +104,7 @@ NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
serializedVersion: 3
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
Expand All @@ -117,7 +117,7 @@ NavMeshSettings:
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
buildHeightMesh: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
Expand Down Expand Up @@ -199,7 +199,9 @@ Canvas:
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 0
m_AdditionalShaderChannelsFlag: 0
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
Expand All @@ -218,7 +220,6 @@ RectTransform:
- {fileID: 1777274299}
- {fileID: 1337286983}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
Expand Down Expand Up @@ -311,13 +312,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
serializedVersion: 2
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &963194225
GameObject:
Expand Down Expand Up @@ -359,9 +360,17 @@ Camera:
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_Iso: 200
m_ShutterSpeed: 0.005
m_Aperture: 16
m_FocusDistance: 10
m_FocalLength: 50
m_BladeCount: 5
m_Curvature: {x: 2, y: 11}
m_BarrelClipping: 0.25
m_Anamorphism: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
Expand Down Expand Up @@ -395,13 +404,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1131137043
GameObject:
Expand All @@ -428,13 +437,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1131137043}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1131137045
MonoBehaviour:
Expand Down Expand Up @@ -462,12 +471,14 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 98622613d505143a9a06b4b11b0a82cf, type: 3}
m_Name:
m_EditorClassIdentifier:
resolution: 3
capabilities: 1
capabilities: 2
playOnAwake: 1
_facing: 0
resolution: 3
frameRate: 30
focusMode: 0
exposureMode: 0
OnFrame:
OnCameraFrame:
m_PersistentCalls:
m_Calls: []
--- !u!1 &1232703155
Expand Down Expand Up @@ -500,6 +511,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SendPointerHoverToParent: 1
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
Expand Down Expand Up @@ -529,13 +541,13 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1232703155}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1337286982
GameObject:
Expand Down Expand Up @@ -568,7 +580,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 411086898}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
Expand Down Expand Up @@ -627,6 +638,7 @@ GameObject:
- component: {fileID: 1777274302}
- component: {fileID: 1777274304}
- component: {fileID: 1777274303}
- component: {fileID: 1777274305}
m_Layer: 5
m_Name: RawImage
m_TagString: Untagged
Expand All @@ -647,7 +659,6 @@ RectTransform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 411086898}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
Expand Down Expand Up @@ -730,3 +741,31 @@ MonoBehaviour:
m_EditorClassIdentifier:
cameraManager: {fileID: 1131137046}
viewMode: 0
focusMode: 0
exposureMode: 0
zoomMode: 0
OnPresent:
m_PersistentCalls:
m_Calls: []
--- !u!114 &1777274305
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1777274298}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0b148fe25e99eb48b9724523833bab1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Delegates: []
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 963194228}
- {fileID: 705507995}
- {fileID: 411086898}
- {fileID: 1232703158}
- {fileID: 1131137044}
4 changes: 2 additions & 2 deletions Assets/DetectionVisualizer.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/*
* BlazePose Detector
* Copyright (c) 2022 NatML Inc. All Rights Reserved.
* Copyright (c) 2023 NatML Inc. All Rights Reserved.
*/

namespace NatML.Examples.Visualizers {

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using NatML.VideoKit.UI;
using NatML.Vision;
using VideoKit.UI;

/// <summary>
/// </summary>
Expand Down
17 changes: 0 additions & 17 deletions BlazePose-Detector.sln

This file was deleted.

3 changes: 3 additions & 0 deletions Packages/ai.natml.vision.blazepose.detector/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.0.3
+ Upgraded to NatML 1.1.16.

## 1.0.2
+ Refactored `BlazePoseDetector.Pose` struct to `Detection`.

Expand Down
21 changes: 6 additions & 15 deletions Packages/ai.natml.vision.blazepose.detector/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BlazePose Detector
[MediaPipe BlazePose](https://google.github.io/mediapipe/solutions/pose.html) for person detection in Unity Engine with [NatML](https://github.com/natmlx/NatML).
[MediaPipe BlazePose](https://google.github.io/mediapipe/solutions/pose.html) for person detection in Unity Engine with [NatML](https://github.com/natmlx/natml-unity).

## Installing BlazePose
Add the following items to your Unity project's `Packages/manifest.json`:
Expand All @@ -9,48 +9,39 @@ Add the following items to your Unity project's `Packages/manifest.json`:
{
"name": "NatML",
"url": "https://registry.npmjs.com",
"scopes": ["ai.natml"]
"scopes": ["ai.fxn", "ai.natml"]
}
],
"dependencies": {
"ai.natml.vision.blazepose.detector": "1.0.2"
"ai.natml.vision.blazepose.detector": "1.0.3"
}
}
```

## Detecting Poses in an Image
First, create the BlazePose detector:
```csharp
// Fetch the model data from NatML
var modelData = await MLModelData.FromHub("@natml/blazepose-detector");
// Deserialize the model
var model = modelData.Deserialize();
// Create the BlazePose detector
var predictor = new BlazePoseDetector(model);
var predictor = await BlazePoseDetector.Create();
```

Then detect pose rectangles in the image:
```csharp
// Create image feature
Texture2D image = ...;
var imageFeature = new MLImageFeature(image);
// Set normalization and aspect mode
(imageFeature.mean, imageFeature.std) = modelData.normalization;
imageFeature.aspectMode = modelData.aspectMode;
// Detect pose regions-of-interest in the image
BlazePoseDetector.Detection[] faces = predictor.Predict(imageFeature);
BlazePoseDetector.Detection[] faces = predictor.Predict(image);
```

___

## Requirements
- Unity 2021.2+
- Unity 2022.3+

## Quick Tips
- Join the [NatML community on Discord](https://hub.natml.ai/community).
- Discover more ML models on [NatML Hub](https://hub.natml.ai).
- See the [NatML documentation](https://docs.natml.ai/unity).
- Discuss [NatML on Unity Forums](https://forum.unity.com/threads/open-beta-natml-machine-learning-runtime.1109339/).
- Contact us at [[email protected]](mailto:[email protected]).

Thank you very much!
Loading

0 comments on commit fee6237

Please sign in to comment.