Skip to content

Commit 3312d62

Browse files
committed
Upgrade to NatML 1.1
1 parent cac2be3 commit 3312d62

File tree

14 files changed

+379
-369
lines changed

14 files changed

+379
-369
lines changed

Assembly-CSharp.csproj

Lines changed: 238 additions & 235 deletions
Large diffs are not rendered by default.

Assets/MeetSample.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Meet
3-
* Copyright (c) 2022 NatML Inc. All Rights Reserved.
3+
* Copyright © 2023 NatML Inc. All Rights Reserved.
44
*/
55

66
namespace NatML.Examples {
@@ -19,20 +19,17 @@ public class MeetSample : MonoBehaviour {
1919
public RawImage rawImage;
2020
public AspectRatioFitter aspectFitter;
2121

22-
private MLModel model;
22+
private MLEdgeModel model;
2323
private MeetPredictor predictor;
2424
private RenderTexture matteTexture;
2525

2626
private async void Start () {
27-
Debug.Log("Fetching model from NatML...");
28-
// Fetch the model data from NatML Hub
29-
var modelData = await MLModelData.FromHub("@natml/meet");
30-
// Create the edge model
31-
model = new MLEdgeModel(modelData);
27+
// Create the model
28+
model = await MLEdgeModel.Create("@natml/meet");
3229
// Create the Meet predictor
3330
predictor = new MeetPredictor(model);
3431
// Listen for camera frames
35-
cameraManager.OnFrame.AddListener(OnCameraFrame);
32+
cameraManager.OnCameraFrame.AddListener(OnCameraFrame);
3633
}
3734

3835
private void OnCameraFrame (CameraFrame frame) {
@@ -46,6 +43,11 @@ private void OnCameraFrame (CameraFrame frame) {
4643
aspectFitter.aspectRatio = (float)matteTexture.width / matteTexture.height;
4744
}
4845

49-
private void OnDisable () => model?.Dispose(); // Dispose model
46+
private void OnDisable () {
47+
// Stop listening for camera frames
48+
cameraManager.OnCameraFrame.RemoveListener(OnCameraFrame);
49+
// Dispose model
50+
model?.Dispose();
51+
}
5052
}
5153
}

Assets/MeetSample.unity

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RenderSettings:
3838
m_ReflectionIntensity: 1
3939
m_CustomReflection: {fileID: 0}
4040
m_Sun: {fileID: 705507994}
41-
m_IndirectSpecularColor: {r: 0.44657838, g: 0.49641234, b: 0.57481676, a: 1}
41+
m_IndirectSpecularColor: {r: 0.4440765, g: 0.49331635, b: 0.57239074, a: 1}
4242
m_UseRadianceAmbientProbe: 0
4343
--- !u!157 &3
4444
LightmapSettings:
@@ -379,11 +379,11 @@ MonoBehaviour:
379379
m_Name:
380380
m_EditorClassIdentifier:
381381
resolution: 3
382-
capabilities: 1
382+
capabilities: 2
383383
playOnAwake: 1
384384
focusMode: 0
385385
exposureMode: 0
386-
OnFrame:
386+
OnCameraFrame:
387387
m_PersistentCalls:
388388
m_Calls: []
389389
--- !u!1 &963194225
@@ -588,6 +588,7 @@ MonoBehaviour:
588588
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
589589
m_Name:
590590
m_EditorClassIdentifier:
591+
m_SendPointerHoverToParent: 1
591592
m_HorizontalAxis: Horizontal
592593
m_VerticalAxis: Vertical
593594
m_SubmitButton: Submit

Packages/ai.natml.vision.meet/Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.0.4
2+
+ Upgraded to NatML 1.1.
3+
14
## 1.0.3
25
+ Fixed incorrect prediction results on WebGL.
36
+ Upgraded to NatML 1.0.18.

Packages/ai.natml.vision.meet/README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,25 @@ Add the following items to your Unity project's `Packages/manifest.json`:
1313
}
1414
],
1515
"dependencies": {
16-
"ai.natml.vision.meet": "1.0.3"
16+
"ai.natml.vision.meet": "1.0.4"
1717
}
1818
}
1919
```
2020

2121
## Predicting the Matte
2222
First, create the predictor:
2323
```csharp
24-
// Fetch the model data from NatML Hub
25-
var modelData = await MLModelData.FromHub("@natml/meet");
26-
// Deserialize the model
27-
var model = modelData.Deserialize();
24+
// Create the model
25+
var model = await MLEdgeModel.Create("@natml/meet");
2826
// Create the Meet predictor
2927
var predictor = new MeetPredictor(model);
3028
```
3129

3230
Then predict the human matte:
3331
```csharp
34-
// Predict
35-
Texture2D image = ...; // This can also be a `WebCamTexture` or any other image feature
32+
// Given an image...
33+
Texture2D image = ...;
34+
// Predict the human matte
3635
MeetPredictor.Matte matte = predictor.Predict(image);
3736
```
3837

@@ -51,8 +50,7 @@ ___
5150
## Quick Tips
5251
- Discover more ML models on [NatML Hub](https://hub.natml.ai).
5352
- See the [NatML documentation](https://docs.natml.ai/unity).
54-
- Join the [NatML community on Discord](https://hub.natml.ai/community).
55-
- Discuss [NatML on Unity Forums](https://forum.unity.com/threads/open-beta-natml-machine-learning-runtime.1109339/).
53+
- Join the [NatML community on Discord](https://natml.ai/community).
5654
- Contact us at [[email protected]](mailto:[email protected]).
5755

5856
Thank you very much!

Packages/ai.natml.vision.meet/Resources/MeetRenderer.compute

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Meet
3-
// Copyright (c) 2022 NatML Inc. All Rights Reserved.
3+
// Copyright (c) 2023 NatML Inc. All Rights Reserved.
44
//
55

66
#pragma kernel CSMain

Packages/ai.natml.vision.meet/Runtime/Matte.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Meet
3-
* Copyright (c) 2022 NatML Inc. All Rights Reserved.
3+
* Copyright © 2023 NatML Inc. All Rights Reserved.
44
*/
55

66
namespace NatML.Vision {

Packages/ai.natml.vision.meet/Runtime/MeetPredictor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Meet
3-
* Copyright (c) 2022 NatML Inc. All Rights Reserved.
3+
* Copyright © 2023 NatML Inc. All Rights Reserved.
44
*/
55

66
namespace NatML.Vision {
@@ -19,8 +19,8 @@ public sealed partial class MeetPredictor : IMLPredictor<MeetPredictor.Matte> {
1919
/// <summary>
2020
/// Create the meet predictor.
2121
/// </summary>
22-
/// <param name="model">Meet ML model.</param>
23-
public MeetPredictor (MLModel model) => this.model = model as MLEdgeModel;
22+
/// <param name="model">Meet model.</param>
23+
public MeetPredictor (MLEdgeModel model) => this.model = model as MLEdgeModel;
2424

2525
/// <summary>
2626
/// Segment a person in an image.

Packages/ai.natml.vision.meet/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "ai.natml.vision.meet",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"displayName": "Meet",
55
"description": "MediaPipe Meet Segmentation for human matting in Unity Engine.",
66
"unity": "2021.2",
77
"dependencies": {
8-
"ai.natml.natml": "1.0.19"
8+
"ai.natml.natml": "1.1.0"
99
},
1010
"keywords": [
1111
"natml",

Packages/manifest.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
}
1010
],
1111
"dependencies": {
12-
"ai.natml.videokit": "0.0.3",
13-
"com.unity.collab-proxy": "1.15.17",
12+
"ai.natml.videokit": "0.0.9",
13+
"com.unity.collab-proxy": "1.17.7",
1414
"com.unity.feature.development": "1.0.1",
15-
"com.unity.ide.rider": "3.0.14",
16-
"com.unity.ide.visualstudio": "2.0.15",
15+
"com.unity.ide.rider": "3.0.18",
16+
"com.unity.ide.visualstudio": "2.0.17",
1717
"com.unity.ide.vscode": "1.2.5",
1818
"com.unity.test-framework": "1.1.31",
1919
"com.unity.textmeshpro": "3.0.6",
2020
"com.unity.timeline": "1.6.4",
2121
"com.unity.ugui": "1.0.0",
22-
"com.unity.visualscripting": "1.7.8",
22+
"com.unity.visualscripting": "1.8.0",
2323
"com.unity.modules.ai": "1.0.0",
2424
"com.unity.modules.androidjni": "1.0.0",
2525
"com.unity.modules.animation": "1.0.0",

Packages/packages-lock.json

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"dependencies": {
33
"ai.natml.hub": {
4-
"version": "1.0.15",
5-
"depth": 2,
4+
"version": "1.0.20",
5+
"depth": 1,
66
"source": "registry",
77
"dependencies": {},
88
"url": "https://registry.npmjs.com"
99
},
1010
"ai.natml.natcorder": {
11-
"version": "1.9.1",
11+
"version": "1.9.3",
1212
"depth": 1,
1313
"source": "registry",
1414
"dependencies": {
@@ -17,7 +17,7 @@
1717
"url": "https://registry.npmjs.com"
1818
},
1919
"ai.natml.natdevice": {
20-
"version": "1.3.1",
20+
"version": "1.3.2",
2121
"depth": 1,
2222
"source": "registry",
2323
"dependencies": {
@@ -26,11 +26,11 @@
2626
"url": "https://registry.npmjs.com"
2727
},
2828
"ai.natml.natml": {
29-
"version": "1.0.19",
29+
"version": "1.1.0",
3030
"depth": 1,
3131
"source": "registry",
3232
"dependencies": {
33-
"ai.natml.hub": "1.0.12"
33+
"ai.natml.hub": "1.0.20"
3434
},
3535
"url": "https://registry.npmjs.com"
3636
},
@@ -44,13 +44,14 @@
4444
"url": "https://registry.npmjs.com"
4545
},
4646
"ai.natml.videokit": {
47-
"version": "0.0.3",
47+
"version": "0.0.9",
4848
"depth": 0,
4949
"source": "registry",
5050
"dependencies": {
51-
"ai.natml.natcorder": "1.9.1",
52-
"ai.natml.natdevice": "1.3.1",
53-
"ai.natml.natml": "1.0.19",
51+
"ai.natml.hub": "1.0.20",
52+
"ai.natml.natml": "1.1.0",
53+
"ai.natml.natcorder": "1.9.3",
54+
"ai.natml.natdevice": "1.3.2",
5455
"ai.natml.natshare": "1.3.0"
5556
},
5657
"url": "https://registry.npmjs.com"
@@ -60,11 +61,11 @@
6061
"depth": 0,
6162
"source": "embedded",
6263
"dependencies": {
63-
"ai.natml.natml": "1.0.19"
64+
"ai.natml.natml": "1.1.0"
6465
}
6566
},
6667
"com.unity.collab-proxy": {
67-
"version": "1.15.17",
68+
"version": "1.17.7",
6869
"depth": 0,
6970
"source": "registry",
7071
"dependencies": {
@@ -91,17 +92,17 @@
9192
"depth": 0,
9293
"source": "builtin",
9394
"dependencies": {
94-
"com.unity.ide.visualstudio": "2.0.15",
95-
"com.unity.ide.rider": "3.0.14",
95+
"com.unity.ide.visualstudio": "2.0.17",
96+
"com.unity.ide.rider": "3.0.18",
9697
"com.unity.ide.vscode": "1.2.5",
9798
"com.unity.editorcoroutines": "1.0.0",
9899
"com.unity.performance.profile-analyzer": "1.1.1",
99100
"com.unity.test-framework": "1.1.31",
100-
"com.unity.testtools.codecoverage": "1.0.1"
101+
"com.unity.testtools.codecoverage": "1.2.2"
101102
}
102103
},
103104
"com.unity.ide.rider": {
104-
"version": "3.0.14",
105+
"version": "3.0.18",
105106
"depth": 0,
106107
"source": "registry",
107108
"dependencies": {
@@ -110,7 +111,7 @@
110111
"url": "https://packages.unity.com"
111112
},
112113
"com.unity.ide.visualstudio": {
113-
"version": "2.0.15",
114+
"version": "2.0.17",
114115
"depth": 0,
115116
"source": "registry",
116117
"dependencies": {
@@ -140,7 +141,7 @@
140141
"url": "https://packages.unity.com"
141142
},
142143
"com.unity.services.core": {
143-
"version": "1.4.0",
144+
"version": "1.7.0",
144145
"depth": 1,
145146
"source": "registry",
146147
"dependencies": {
@@ -169,7 +170,7 @@
169170
"url": "https://packages.unity.com"
170171
},
171172
"com.unity.testtools.codecoverage": {
172-
"version": "1.0.1",
173+
"version": "1.2.2",
173174
"depth": 1,
174175
"source": "registry",
175176
"dependencies": {
@@ -209,7 +210,7 @@
209210
}
210211
},
211212
"com.unity.visualscripting": {
212-
"version": "1.7.8",
213+
"version": "1.8.0",
213214
"depth": 0,
214215
"source": "registry",
215216
"dependencies": {

ProjectSettings/PackageManagerSettings.asset

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,20 @@ MonoBehaviour:
2525
m_Scopes: []
2626
m_IsDefault: 1
2727
m_Capabilities: 7
28-
- m_Id: scoped:NatML
28+
m_ConfigSource: 0
29+
- m_Id: scoped:project:NatML
2930
m_Name: NatML
3031
m_Url: https://registry.npmjs.com
3132
m_Scopes:
3233
- ai.natml
3334
m_IsDefault: 0
3435
m_Capabilities: 0
36+
m_ConfigSource: 4
3537
m_UserSelectedRegistryName: NatML
3638
m_UserAddingNewScopedRegistry: 0
3739
m_RegistryInfoDraft:
3840
m_Modified: 0
3941
m_ErrorMessage:
40-
m_UserModificationsInstanceId: -828
41-
m_OriginalInstanceId: -830
42+
m_UserModificationsInstanceId: -846
43+
m_OriginalInstanceId: -850
4244
m_LoadAssets: 0

ProjectSettings/ProjectVersion.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
m_EditorVersion: 2021.3.4f1
2-
m_EditorVersionWithRevision: 2021.3.4f1 (cb45f9cae8b7)
1+
m_EditorVersion: 2021.3.17f1
2+
m_EditorVersionWithRevision: 2021.3.17f1 (3e8111cac19d)

0 commit comments

Comments
 (0)