1 # Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
3 @page lightnet_usecase1 LightNet Workflow
5 @note SW Release Applicability: This tutorial is applicable to modules in **NVIDIA DRIVE Software** releases.
9 LightNet module creates an LightNet handle ( `dwLightNetHandle_t` ) that is owned by the application and must be released by the application when it's not needed anymore.
11 `dwLightNetParams` documents the specs of the LightNet model to be loaded and initialized. These parameters determine which precision, optimized processor, and type of LightNet to be loaded and can affect the speed of the inference significantly. To initialize LightNet parameters with default values:
14 dwStatus dwLightNet_initDefaultParams(dwLightNetParams* params);
17 To initialize a pointer to LightNet handle with the designated values of `dwLightNetParams` call:
20 dwStatus dwLightNet_initialize(dwLightNetHandle_t* lightNetHandle,
21 const dwLightNetParams* lightNetParams,
22 dwContextHandle_t ctx);
25 An example code snippet to initialize an LightNet module with a customized FP32 LightNet model that is optimized to perform inference on GPU:
27 dwLightNetHandle_t lightNet;
28 dwLightNetParams lightNetParams{};
29 dwLightNet_initDefaultParams(&lightNetParams);
30 lightNetParams.networkModel = DW_LIGHTNET_MODEL_CUSTOM;
31 lightNetParams.networkCustomData = "my_lightnet_model";
32 lightNetParams.batchSize = DW_LIGHTNET_BATCH_SIZE_1;
33 CHECK_DW_ERROR(dwLightNet_initialize(&lightNet, &lightNetParams, context));
35 Note that `dwLightNet_initDefaultParams()` set `lightNetParams.networkPrecision`, `lightNetParams.batchSize` and `lightNetParams.processorType` to their default values of `DW_PRECISION_FP32`, `DW_LIGHTNET_BATCH_SIZE_1` and `DW_PROCESSOR_TYPE_GPU`, respectively. It is assuming that "my_lightnet_model" file exists in data/resources sub-directory.
38 ## Query Network Specs
40 With the provided APIs, you can query the input blob dimension that the initialized LightNet expects:
43 dwStatus dwLightNet_getInputBlobsize(dwBlobSize* inputBlobsize, dwLightNetHandle_t obj);
47 or get the pointer to the label of the provided class index:
49 dwStatus dwLightNet_getTypeLabel(const char** classLabel, uint32_t classIdx, dwLightNetHandle_t obj);
53 or even the meta data which contains preprocessing configuration of the network:
55 dwStatus dwLightNet_getDNNMetaData(dwDNNMetaData* metaData, dwLightNetHandle_t obj);
61 Finally, to release the LightNet module at the end of the application:
63 dwStatus dwLightNet_release(dwLightNetHandle_t obj);
67 @ref waitcondition_usecase1 shows in more details how to employ LightNet with ObjectClassifier after initialization. For more concrete usage please refer to @ref dwx_light_classification_sample