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

@@ -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>