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
course = courselist.courses[courselist.currentCourseIndex];
//feedback.signPredictor.model = course.theme.model;
feedback.signPredictor.modelList.SetCurrentModel(course.theme.modelIndex);
//feedback.signPredictor.model = feedback.signPredictor.modelList.models[feedback.signPredictor.modelList.currentModelIndex].model;
feedback.signPredictor.ChangeModel(course.theme.modelIndex);
maxWords = course.theme.learnables.Count;
// vvv TEMPORARY STUFF vvv

View File

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

View File

@@ -18,13 +18,10 @@ namespace Mediapipe.Unity.Tutorial
{
public class SignPredictor : MonoBehaviour
{
public ModelList modelList;
/// <summary>
/// Reference to the model used in the SignPredictor
/// ModelList, used to change model using ModelIndex
/// </summary>
public NNModel model;
public ModelList modelList;
/// <summary>
/// Reference to the model info file
@@ -213,12 +210,22 @@ namespace Mediapipe.Unity.Tutorial
// check if model exists at path
//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(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>
/// Coroutine which executes the mediapipe pipeline
/// </summary>

View File

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