I’m using Tensorflow.NET to do machine learning in Unity. The output of this model will be displayed in Unity by capturing a webcam screenshot as the input and returning a heatmap as it’s output, which is computed when the webcam is paused.
The model/code appears to work inside of VS alone, but when running the game in Unity it returns the following error: Assets\Scripts\TestGUI.cs(9,7): error CS0246: The type or namespace name ‘Tensorflow’ could not be found (are you missing a using directive or an assembly reference?)
using UnityEngine;
using UnityEngine.UI;
using System;
using System.IO;
using System.Collections;
using NumSharp;
using Tensorflow;
using static Tensorflow.Binding;
It appears fine in VS, so I’m assuming this has something to do in Unity.
External dependencies in source form can be dropped into asset folder, an they’ll be compiled - IF unity can compile them. To prevent frequent and slow recompilation some people drop them into “Plugins” folder. At least that used to be a practice some time ago.
A dll needs to be dragged into project. See the link for more info.
So I added the dll files from “C:\Users\Me\source\repos\ArRobotVis\bin\Debug\netcoreapp3.1” into a “Plugins” folder in Unity, but I get the following errors:
Assembly 'Library/ScriptAssemblies/Assembly-CSharp.dll' will not be loaded due to errors:
Reference has errors 'TensorFlow.NET'.
Assembly 'Assets/Plugins/NumSharp.Core.dll' will not be loaded due to errors:
Unable to resolve reference 'System.Runtime.CompilerServices.Unsafe'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Unable to resolve reference 'System.Memory'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Assembly 'Assets/Plugins/Google.Protobuf.dll' will not be loaded due to errors:
Unable to resolve reference 'System.Memory'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Assembly 'Assets/Plugins/Sylvester.tf.Api.dll' will not be loaded due to errors:
Unable to resolve reference 'System.Memory'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Unable to resolve reference 'System.Runtime.CompilerServices.Unsafe'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Assembly 'Assets/Plugins/Protobuf.Text.dll' will not be loaded due to errors:
Reference has errors 'Google.Protobuf'.
Assembly 'Assets/Plugins/TensorFlow.NET.dll' will not be loaded due to errors:
Unable to resolve reference 'System.Memory'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Unable to resolve reference 'System.Runtime.CompilerServices.Unsafe'. Is the assembly missing or incompatible with the current platform?
Reference validation can be disabled in the Plugin Inspector.
Both ‘System.Memory’ and ‘System.Runtime.CompilerServices.Unsafe’ are packages in VS, I’m assuming they don’t exist in Unity. I cannot seem to find the dll’s for these, however. Do you know where they would be stored?