DENK SDK Quickstart Guide
This quickstart guide will help you understand how to use our SDK to call neural networks, called models, created on the DENK Vision AI Hub. These models can be downloaded as .denk
files.
The main purpose of the SDK is to run neural network inference offline, locally, on premise and using your own program code.
Depending on your programming language of choice the main functions you have to call are the following:
- Python
- C#
import denk_sdk
pipeline = denk_sdk.InferencePipeline(token=token, device=device)
model = pipeline.add_model(model_path)
results = pipeline.run(img).get_results()
print(results) # contains objects, classification, texts etc.
using DenkSdk;
InferencePipeline pipeline = new InferencePipeline(device, token);
pipeline.AddModel(modelPath);
var results = pipeline.Run(imagePath).GetResults();
Console.WriteLine($"Results: '{results}'"); // contains objects, classification, texts etc.
Check out our fully functional examples here to get started immediately.
The next part shows a step-by-step instruction to setup your system and utilize the DENK SDK for your use-case.
Prerequisites
General
- Access to the denkweit platform
.denk
model files downloaded from the platform- Valid authentication token or dongle (contact your denkweit customer success)
System
- Currently only x86 64bit systems are supported. ARM Processors will be supported soon.
- The DENK SDK is currently available for C# and Python.
- C++ users can use our dynamic link library directly.
- Windows:
- You need Windows 10 or above
- Install the Visual C++ Redistributable: vcredist
- Linux:
- Ubuntu 22.04
- If you want to use other distros contact us here
Check your hardware. Neural Networks run a lot faster on graphic cards (GPUs) than on normal processors (CPUs). You have to choose the right installation package to fully utilize your system. More info here.
Programming language
- Python
- C#
Python 3.8 or higher is required.
If you do not have Python installed on your system, you can download it from the official website. To use the DENK SDKs, we recommend using at least Python Version 3.8, but newer versions will work as well. To run a Python script, in this example a file called script.py
, you can open a terminal window and simply enter:
python script.py
- .NET Framework or .NET Core
- Visual Studio (or another C# IDE)
Installation
All packages can be downloaded from the DENKVision AI Hub Software Center.
- Python
- C#
Windows
-
Download the appropriate wheel file (
.whl
) from our hub. For now the standard "DENK SDK Python", which uses DML, supports CPU and GPU execution. Advanced use cases can use CUDA or OpenVino directly (more information). -
Install the wheel:
pip install denk_sdk_v1.0.0.whl
Linux
Packages are compiled for Ubuntu 22.04. If you encounter problems or are in need of a package for a different distro contact use here.
- Download the appropriate wheel file (
.whl
) for your system:- CPU:
denk_sdk_lin_cpu_v1.0.0.whl
- NVIDIA GPU:
denk_sdk_lin_gpu_v1.0.0.whl
- CPU:
- Install the wheel:
pip install <wheel_name>.whl
Windows and Linux
-
Download the appropriate wheel file (
.nupkg
) from our hub. For now the standard "DENK SDK C# (NuGet)", which uses DML, supports CPU and GPU execution. Advanced use cases can use CUDA or OpenVino directly. -
Install the package in your project:
dotnet add package denk_sdk_win_csharp_v1.0.0.nupkg
Usage
The following is a first simple example showing the basic usage.
There are more advanced "ready-to-use" programs in this documentation here and information on the structure of the returning result here.
- Python
- C#
import denk_sdk
import cv2
with open("token.txt", 'r') as file:
token = file.read()
model_path = "models/my_segmentation_model.denk"
example_image = cv2.imread("my_image.jpg")
# model loading and definiton, only done once
pipeline = denk_sdk.InferencePipeline(token=token, device=denk_sdk.Device.CPU)
model = pipeline.add_model(model_path)
model.post.set_segmentation_threshold(0.1).set_confidence_filter(0.992)
# run the model
results = pipeline.run(example_image).get_results()
for m in results.segmentation_models:
print("Model: {}".format(m.model_name))
for cl in m.classes:
print(" Class: {}".format(cl.class_name))
for ftr in cl.objects:
print(" Feature: {}".format(ftr.confidence))
using DenkSdk;
using Google.Protobuf;
string resourceDir = Environment.GetEnvironmentVariable("RESOURCE_DIR") ?? throw new Exception("Could not get RESOURCE_DIR environment variable");
string tokenPath = Path.Combine(resourceDir, "authentication", "Token.txt");
string token = File.ReadAllText(tokenPath);
InferencePipeline pipeline = new InferencePipeline(DenkSdk.Device.CPU, token);
string modelPath = Path.Combine(resourceDir, "models", "Fruits_02_2024_Segm.denk");
string imagePath = Path.Combine(resourceDir, "images", "IMG_1999.JPG");
pipeline.AddModel(modelPath);
var results = pipeline.Run(imagePath).GetResults();
using (var output = File.Create("results.bin"))
{
res
}