0

I'm trying to embed a model that I trained in my c# unity script. By doing something like this

using UnityEngine;
using UnityEngine.UI;
using MLAgents;

public class loadImage : MonoBehaviour {

    public NNModel modelSource;

    var model = ModelLoader.Load(modelSource);

This was prescribed by these barracuda docs on unity's github. However, i get the error

The type or namespace 'NModel' could not be found. Are you missing a using directive or assembly reference?

Don't really know how I could be adding that Quite new to c# and Unity programming, so the cause for this error could be rather basic. Am I forgetting something?

Thanks!

SumakuTension
  • 542
  • 1
  • 9
  • 26

2 Answers2

2

Although I am late to the party, just in case someone is still struggling with this problem, simply add:

using Unity.Barracuda;

instead of

using Barracuda;

solved my issue

Wai Pui
  • 21
  • 1
  • 2
1

You can see e.g. in BarracudaModelParamLoader the only namespace besides the System ones is Barracula and it uses NModel ;)

So NModel seems to be part of the Barracula namespace.

Simply add

using Barracuda;

at the top of your script.

Also make sure that the Baracccula .dll files are imported and compatible with the target platform.


In general: I would strongly recommend to use a proper IDE like e.g. VisualStudio for doing your coding. It usually can automatically suggest the required fixes for missing namespaces.

derHugo
  • 83,094
  • 9
  • 75
  • 115