Last active
February 26, 2020 17:03
-
-
Save asus4/4da31a3c682e8c99914afb5fb81dcc0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the image 28 * 28 grayscale | |
float[,] inputs = new float[28, 28]; | |
// the array of probability | |
float[] outputs = new float[10]; | |
void Start() | |
{ | |
// Read bytes from model and make Interpreter | |
interpreter = new Interpreter(File.ReadAllBytes(path)); | |
// Allocate input buffer | |
interpreter.ResizeInputTensor(0, new int[] { 1, 28, 28, 1 }); | |
interpreter.AllocateTensors(); | |
} | |
void Update() | |
{ | |
// Set input data | |
interpreter.SetInputTensorData(0, inputs); | |
// Blackbox!! | |
interpreter.Invoke(); | |
// Get data | |
interpreter.GetOutputTensorData(0, outputs); | |
} | |
void OnDestroy() | |
{ | |
interpreter?.Dispose(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment