Resolve WES-100 "Natml integration"

This commit is contained in:
Jelle De Geest
2023-04-03 14:14:49 +00:00
parent edf1805a92
commit f95e34c6fe
425 changed files with 525 additions and 96655 deletions

View File

@@ -2,7 +2,8 @@
"name": "InterfacesScripts",
"rootNamespace": "",
"references": [
"GUID:5c2b5ba89f9e74e418232e154bc5cc7a"
"GUID:5c2b5ba89f9e74e418232e154bc5cc7a",
"GUID:d23f64cfd3b314bb4a18a8284c99bf5e"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@@ -1,7 +1,6 @@
fileFormatVersion: 2
guid: 7f2d0ee6dd21e1d4eb25b71b7a749d25
folderAsset: yes
DefaultImporter:
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:

View File

@@ -6,6 +6,6 @@ using UnityEngine;
/// </summary>
public enum ModelIndex
{
FINGERSPELLING,
NONE
NONE,
FINGERSPELLING
}

View File

@@ -1,8 +1,7 @@
using NatML;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Barracuda;
/// <summary>
/// This scriptable will hold tupples of Courseindices and models
/// </summary>
@@ -22,28 +21,49 @@ public class ModelList : ScriptableObject
/// <summary>
/// The model itself
/// </summary>
public NNModel model;
public MLModelData modelWINDOWS;
/// <summary>
/// The model itself
/// </summary>
public MLModelData modelMAC;
}
/// <summary>
/// Index of the currently active model
/// </summary>
public int currentModelIndex = 0;
/// <summary>
/// A list of all the models
/// </summary>
public List<ModelTuple> models = new List<ModelTuple>();
/// <summary>
/// Index of the currently active model
/// </summary>
public int currentModelIndex = 0;
/// <summary>
/// Get a model by modelindex
/// </summary>
/// <param name="modelIndex">ModelIndex of the model</param>
/// <returns>Model associated with this index, null if no model was found</returns>
public NNModel GetCurrentModel()
public MLModelData GetCurrentModel()
{
return models.Find(x => x.model == models[currentModelIndex].model)?.model;
// Select Model based on OS
#if (UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN)
return models.Find(x => x.modelWINDOWS == models[currentModelIndex].modelWINDOWS)?.modelWINDOWS;
#elif (UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX)
return models.Find(x => x.modelMAC == models[currentModelIndex].modelMAC)?.modelMAC;
#endif
return null;
}
/// <summary>
/// Function to check if the modelIndex has been set
/// </summary>
/// <returns></returns>
public bool HasValidModel()
{
return models[currentModelIndex].index != (int)ModelIndex.NONE;
}
/// <summary>

View File

@@ -27,6 +27,7 @@ public class Theme : ScriptableObject
/// </summary>
public ModelIndex modelIndex;
/// <summary>
/// List of all learnable words/letters
/// </summary>

View File

@@ -7,10 +7,4 @@ ScriptedImporter:
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 683b6cb6d0a474744822c888b46772c9, type: 3}
optimizeModel: 1
forceArbitraryBatchSize: 1
treatErrorsAsWarnings: 0
importMode: 1
weightsTypeMode: 0
activationTypeMode: 0
script: {fileID: 11500000, guid: 8264490bef67c46f2982e6dd3f5e46cd, type: 3}

Binary file not shown.

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: fdbf401e965a6bf4a87637cd519f2715
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 8264490bef67c46f2982e6dd3f5e46cd, type: 3}

View File

@@ -15,7 +15,7 @@ MonoBehaviour:
title: Handalfabet
description: Van A tot Z
index: 0
model: {fileID: 5022602860645237092, guid: e6d85df707405ad4f97c23b07227ee99, type: 3}
modelIndex: 1
learnables:
- name: A
image: {fileID: 21300000, guid: 4eb4ef55f866f114dafb722f4bd05c76, type: 3}

View File

@@ -6,8 +6,8 @@
"UnityEditor.TestRunner",
"CommonScripts",
"InterfacesScripts",
"Unity.Barracuda",
"SignPredictor"
"SignPredictor",
"NatML.ML"
],
"includePlatforms": [
"Editor"

View File

@@ -1,5 +1,5 @@
using NatML;
using NUnit.Framework;
using Unity.Barracuda;
using UnityEngine;
/// <summary>
/// Test the ModelList class
@@ -45,7 +45,11 @@ public class ModelListTest
ModelIndex value = (ModelIndex)random.Next(modelList.models.Count);
modelList.SetCurrentModel(value);
Assert.AreEqual(modelList.models[modelList.currentModelIndex].model, modelList.GetCurrentModel());
#if (UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN)
Assert.AreEqual(modelList.models[modelList.currentModelIndex].modelWINDOWS, modelList.GetCurrentModel());
#elif (UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX)
Assert.AreEqual(modelList.models[modelList.currentModelIndex].modelMAC, modelList.GetCurrentModel());
#endif
// Check if empty model fails gracefully (returns null)
Assert.IsNull(ScriptableObject.CreateInstance<ModelList>().GetCurrentModel());
@@ -69,7 +73,11 @@ public class ModelListTest
ModelList.ModelTuple m = modelList.models[modelList.currentModelIndex];
Assert.AreEqual(m.index, value);
Assert.IsTrue(m.model is NNModel || m.model is null);
#if (UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN)
Assert.IsTrue(m.modelWINDOWS is MLModelData || m.modelWINDOWS is null);
#elif (UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX)
Assert.IsTrue(m.modelMAC is MLModelData || m.modelMAC is null);
#endif
}
}
ModelList emptyList = ScriptableObject.CreateInstance<ModelList>();