Examples
-
Example implementation of loading an image, passing it through a model, and receiving the resulting image
-
The constants at the top should be modified by the user:
- INPUT_PATH : Path to the input image
- OUTPUT_PATH : Path to the output image
- ONNX_PATH : Path to the ONNX file
- DEVICE : Device to execute the model
- Input "{GPU_ID}" or "cpu" ex) "0"
- CELL_TYPE : Type of cell to be inspected
- CellType may vary for each client
- Check the types in include/type.h
#include "api.h"
const std::string INPUT_PATH = "path/to/input.jpg";
const std::string OUTPUT_PATH = "path/to/output.jpg";
const std::string ONNX_PATH = "path/to/onnxFile.onnx";
const std::string DEVICE = "0";
const CellType CELL_TYPE = CellType::CYLINDER_TOP;
int main()
{
ModelConfig mc = CreateModelConfig(
DEVICE,
ONNX_PATH,
CELL_TYPE
);
Model* model = CreateModel(mc);
Mat image = imread(INPUT_PATH, 1);
ModelResult mr = RunModel(model, image);
// mask
Mat maskImage = GetMaskByClassID(mr, 0);
SaveResultImage(maskImage, OUTPUT_PATH);
Mat maskImage = GetMaskVisualizationForAllClasses(mr);
SaveResultImage(maskImage, OUTPUT_PATH);
// skeleton
Mat maskImage = GetSkeletonVisualizationForAllClasses(mr);
SaveResultImage(maskImage, OUTPUT_PATH);
DeleteInspector(inspector);
}
-
explanation:
Fetch details regarding the Mask/Skeleton images.Mat maskImage = GetMaskByClassID(mr, 0); // Return a binary image of a specific class ID Mat maskImage = GetMaskVisualizationForAllClasses(mr); // Mask visualization image Mat maskImage = GetSkeletonVisualizationForAllClasses(mr); // Skeleton visualization image
This functionality is interchangeable with different functions based on specific needs.For instance, it can be tailored to provide information exclusively for particular classes, or to return data of type UCHAR, or even when solely the mask is required without any visualization.
Please consult the Interfaces page for further guidance.
Note that the function's interface may vary depending on the client's requirements.