The number of samples for expression learning is now 1000 per expression, because gathering the maximum number of samples is no longer enforced.

This commit is contained in:
Emiliana 2020-02-10 21:46:01 +01:00
parent e83e965290
commit 443a7ee88e
3 changed files with 7 additions and 7 deletions

View file

@ -41,7 +41,7 @@ public class OpenSeeExpression : MonoBehaviour
[Tooltip("When enabled, the expression data will be saved to the specified filename and this flag is set back to false.")] [Tooltip("When enabled, the expression data will be saved to the specified filename and this flag is set back to false.")]
public bool save = false; public bool save = false;
[Header("Information")] [Header("Information")]
[Tooltip("This is the of expressions for which calibration data was collected. The maximum number is 25.")] [Tooltip("This is the of expressions for which calibration data was collected. The maximum number is 10.")]
public int expressionNumber = 0; public int expressionNumber = 0;
[Tooltip("This is the percentage of necessary training data collected for the current expression.")] [Tooltip("This is the percentage of necessary training data collected for the current expression.")]
public float percentRecorded = 0.0f; public float percentRecorded = 0.0f;
@ -99,7 +99,7 @@ public class OpenSeeExpression : MonoBehaviour
private Dictionary<string, List<float[]>> expressions; private Dictionary<string, List<float[]>> expressions;
private SVMModel model = null; private SVMModel model = null;
private string[] classLabels = null; private string[] classLabels = null;
private int maxSamples = 400; // Allows 25 expressions without exceeding 10000 rows in total for SVM training, which is a commonly seen upper limit. private int maxSamples = 1000; // Allows 10 expressions without exceeding 10000 rows in total for SVM training, which is a commonly seen upper limit.
// rightEyeOpen, leftEyeOpen, translation, rawQuaternion, rawEuler, confidence, points/(width, height), points3D // rightEyeOpen, leftEyeOpen, translation, rawQuaternion, rawEuler, confidence, points/(width, height), points3D
private int cols = 1 + 1 + 3 + 4 + 3 + /*66 + 2 * 66 +*/ 3 * 66; private int cols = 1 + 1 + 3 + 4 + 3 + /*66 + 2 * 66 +*/ 3 * 66;
private double lastCapture = 0.0; private double lastCapture = 0.0;
@ -197,8 +197,8 @@ public class OpenSeeExpression : MonoBehaviour
} }
} }
int classes = keys.Count; int classes = keys.Count;
if (classes < 2 || classes > 25) { if (classes < 2 || classes > 10) {
Debug.Log("[Training error] The number of expressions that can be used for training is " + classes + ", which is either below 2 or higher than 25."); Debug.Log("[Training error] The number of expressions that can be used for training is " + classes + ", which is either below 2 or higher than 10.");
return false; return false;
} }
keys.Sort(); keys.Sort();
@ -301,7 +301,7 @@ public class OpenSeeExpression : MonoBehaviour
recordingSkip = 1; recordingSkip = 1;
if (calibrationExpression == "") if (calibrationExpression == "")
return false; return false;
if (expressions.ContainsKey(calibrationExpression) || expressions.Keys.Count < 25) { if (expressions.ContainsKey(calibrationExpression) || expressions.Keys.Count < 10) {
OpenSee.OpenSeeData[] openSeeData = openSee.trackingData; OpenSee.OpenSeeData[] openSeeData = openSee.trackingData;
if (openSeeData == null) if (openSeeData == null)
return false; return false;

View file

@ -12,7 +12,7 @@ namespace OpenSee {
public class SVMModel { public class SVMModel {
#region DllImport #region DllImport
[DllImport("SVMModel", CallingConvention = CallingConvention.Cdecl)] [DllImport("SVMModel", CallingConvention = CallingConvention.Cdecl)]
private static extern System.IntPtr trainModel(float[] features, float[] labels, int rows, int cols); private static extern System.IntPtr trainModel(float[] features, float[] labels, int rows, int cols, float C);
[DllImport("SVMModel", CallingConvention = CallingConvention.Cdecl)] [DllImport("SVMModel", CallingConvention = CallingConvention.Cdecl)]
private static extern void predict(System.IntPtr model, float[] features, [Out] float[] predictions, int rows); private static extern void predict(System.IntPtr model, float[] features, [Out] float[] predictions, int rows);
@ -143,7 +143,7 @@ public class SVMModel {
maxClasses = max + 1; maxClasses = max + 1;
this.cols = cols; this.cols = cols;
model = trainModel(features, labels, rows, cols); model = trainModel(features, labels, rows, cols, 32f);
haveModel = true; haveModel = true;
return true; return true;

Binary file not shown.