Made modelChanging internal in SIgnPredictor

Made it so that there is a function inside SignPredictor that is used to change its model
This commit is contained in:
CoudronJerome
2023-03-26 23:15:09 +02:00
parent 51ee8b0658
commit 78f4d961f7
4 changed files with 16 additions and 12 deletions

View File

@@ -128,9 +128,7 @@ public class TemplateCourse : MonoBehaviour
{ {
// Setting up course // Setting up course
course = courselist.courses[courselist.currentCourseIndex]; course = courselist.courses[courselist.currentCourseIndex];
//feedback.signPredictor.model = course.theme.model; feedback.signPredictor.ChangeModel(course.theme.modelIndex);
feedback.signPredictor.modelList.SetCurrentModel(course.theme.modelIndex);
//feedback.signPredictor.model = feedback.signPredictor.modelList.models[feedback.signPredictor.modelList.currentModelIndex].model;
maxWords = course.theme.learnables.Count; maxWords = course.theme.learnables.Count;
// vvv TEMPORARY STUFF vvv // vvv TEMPORARY STUFF vvv

View File

@@ -242,7 +242,7 @@ public class HangmanGameController : MonoBehaviour
userList.Save(); userList.Save();
// Hangman always uses fingerspelling // Hangman always uses fingerspelling
feedback.signPredictor.model = feedback.signPredictor.modelList.GetModelByIndex(ModelIndex.FINGERSPELLING); feedback.signPredictor.ChangeModel(ModelIndex.FINGERSPELLING);
// Set calllbacks // Set calllbacks
feedback.getSignCallback = () => feedback.getSignCallback = () =>

View File

@@ -18,13 +18,10 @@ namespace Mediapipe.Unity.Tutorial
{ {
public class SignPredictor : MonoBehaviour public class SignPredictor : MonoBehaviour
{ {
public ModelList modelList;
/// <summary> /// <summary>
/// Reference to the model used in the SignPredictor /// ModelList, used to change model using ModelIndex
/// </summary> /// </summary>
public NNModel model; public ModelList modelList;
/// <summary> /// <summary>
/// Reference to the model info file /// Reference to the model info file
@@ -213,12 +210,22 @@ namespace Mediapipe.Unity.Tutorial
// check if model exists at path // check if model exists at path
//var model = ModelLoader.Load(Resources.Load<NNModel>("Models/Fingerspelling/model_A-L")); //var model = ModelLoader.Load(Resources.Load<NNModel>("Models/Fingerspelling/model_A-L"));
worker = model.CreateWorker(); worker = modelList.models[modelList.currentModelIndex].model.CreateWorker();
StartCoroutine(SignRecognitionCoroutine()); StartCoroutine(SignRecognitionCoroutine());
StartCoroutine(MediapipeCoroutine()); StartCoroutine(MediapipeCoroutine());
} }
public void ChangeModel(ModelIndex index)
{
this.modelList.SetCurrentModel(index);
// If a worker already existed, we throw it out
worker?.Dispose();
// Add a new worker for the new model
worker = modelList.models[modelList.currentModelIndex].model.CreateWorker();
}
/// <summary> /// <summary>
/// Coroutine which executes the mediapipe pipeline /// Coroutine which executes the mediapipe pipeline
/// </summary> /// </summary>

View File

@@ -182,8 +182,7 @@ public partial class GameController : MonoBehaviour
userList.Save(); userList.Save();
currentTheme = minigame.themeList.themes[minigame.themeList.currentThemeIndex]; currentTheme = minigame.themeList.themes[minigame.themeList.currentThemeIndex];
//feedback.signPredictor.model = currentTheme.model; feedback.signPredictor.ChangeModel(currentTheme.modelIndex);
feedback.signPredictor.model = feedback.signPredictor.modelList.GetModelByIndex(currentTheme.modelIndex);
words.AddRange(currentTheme.learnables); words.AddRange(currentTheme.learnables);
ShuffleWords(); ShuffleWords();
NextWord(); NextWord();