Using Emgu TF Lite with .Net Core

From Emgu CV: OpenCV in .NET (C#, VB, C++ and more)
Jump to: navigation, search

Software requirements

The latest Emgu TF Lite development code contains a Inception.Console.Lite.Netstandard demo that can be run as a .Net Core console application. You will need to check out the lastest development code from GitHub to test this

Emgu.TF.Lite.Models.Netstandard

The Inception.Console.Lite.Netstandard demo code depends on Emgu.TF.Lite.Models.Netstandard component, that has a dependency on System.Drawing.Common, which again, has a dependency on native libgdiplus library.

If you are not using Emgu.TF.Lite.Models library in your own project, you can skip this part. You will need to implement your own code to convert the image file to a TfLite tensor.

If you are following the Inception.Console.Lite.Netstandard demo, you will need to install libgpiplus for your platform.

Windows

All windows release comes with libgdiplus, no additional action is required.

macOS

First, you should install home brew. Once homebrew is installed, you can install libgdiplus by calling:

brew install mono-libgdiplus

Ubuntu

You can install libgdiplus by calling:

sudo apt-get install libgdiplus

Getting the native tensorflow lite binary

If you are using the release package, you already have the prebuild binary in place. If you need to build the tfliteextern native binary from source code, you can use the build script in the "Platforms" folder.

Building the .NetCore console demo

In a terminal, go to the "Emgu.TF.Example\Inception.Console.Lite.Netstandard" folder, and run the following command:

dotnet build

Running the .NetCore console demo

In a terminal, go to the "lib" folder, where the Inception.Console.Lite.Netstandard.dll is build, and run the following command:

dotnet Inception.Console.Lite.Netstandard.dll

The application should try to download the Inception model from the internet and use it to recognize the flower type.