SumakuTension
SumakuTension

Reputation: 552

The type or namespace 'NModel' could not be found

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!

Upvotes: 0

Views: 1503

Answers (2)

Wai Pui
Wai Pui

Reputation: 21

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

Upvotes: 2

derHugo
derHugo

Reputation: 90669

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.

Upvotes: 1

Related Questions