Get started
This chapter introduces how to apply Mech-DLK SDK to achieve inference using a defect segmentation model exported from Mech-DLK.
Prerequisites
-
Connect the license dongle provided by Mech-Mind to your device.
-
Make sure that CodeMeter is running: In the system tray, check if the CodeMeter icon is displayed in the Windows tray.
If you have installed Mech-DLK on your device, you don’t have to install CodeMeter again because it’s already in place. Check the Windows tray to make sure that CodeMeter is running. |
Function description
In this section, we take the Defect Segmentation model exported from Mech-DLK as an example to show the functions you need to use when using Mech-DLK SDK for model inference.
Create an input image
Call the following function to create an input image.
-
C#
-
C
MMindImage image = new MMindImage();
image.CreateFromPath("path/to/image.png");
List<MMindImage> images = new List<MMindImage> { image };
MMindImage input;
createImage("path/to/image.png", &input);
Create an inference engine
Call the following function to create an inference engine.
-
C#
-
C
InferEngine inferEngine = new InferEngine();
inferEngine.Create("path/to/xxx.dlkpack", BackendType.GpuDefault, 0);
|
Engine engine;
createPackInferEngine(&engine, "path/to/xxx.dlkpack", GpuDefault, 0);
|
Deep learning engine inference
Call the function below for deep learning engine inference.
-
C#
-
C
inferEngine.Infer(images);
infer(&engine, &input, 1);
In this function, the parameter 1 denotes the number of images for inference, which should equal the number of images in input .
|
Obtain the defect segmentation result
Call the function below to obtain the defect segmentation result.
-
C#
-
C
List<Result> results;
inferEngine.GetResults(out results);
DefectAndEdgeResult* defectAndEdgeResult = NULL;
unsigned int resultNum = 0;
getDefectSegmentataionResult(&engine, 0, &defectAndEdgeResult, &resultNum);
In this function, the second parameter
|
Result visualization
Call the function below to visualize the model inference result.
-
C#
-
C
inferEngine.ResultVisualization(images);
image.Show("result");
resultVisualization(&engine, &input, 1);
showImage(&input, "result");
In this function, the parameter 1 denotes the number of images for inference, which should equal the number of images in input .
|