create_dl_modelT_create_dl_modelCreateDlModelCreateDlModelcreate_dl_model (Operator)

Name

create_dl_modelT_create_dl_modelCreateDlModelCreateDlModelcreate_dl_model — Create a deep learning model.

Signature

create_dl_model( : : OutputLayers : DLModelHandle)

Herror T_create_dl_model(const Htuple OutputLayers, Htuple* DLModelHandle)

void CreateDlModel(const HTuple& OutputLayers, HTuple* DLModelHandle)

void HDlModel::HDlModel(const HDlLayerArray& OutputLayers)

void HDlModel::HDlModel(const HDlLayer& OutputLayers)

void HDlModel::CreateDlModel(const HDlLayerArray& OutputLayers)

void HDlModel::CreateDlModel(const HDlLayer& OutputLayers)

static void HOperatorSet.CreateDlModel(HTuple outputLayers, out HTuple DLModelHandle)

public HDlModel(HDlLayer[] outputLayers)

public HDlModel(HDlLayer outputLayers)

void HDlModel.CreateDlModel(HDlLayer[] outputLayers)

void HDlModel.CreateDlModel(HDlLayer outputLayers)

def create_dl_model(output_layers: MaybeSequence[HHandle]) -> HHandle

Description

The operator create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelCreateDlModelcreate_dl_model creates a deep learning model from a graph and returns its handle in DLModelHandleDLModelHandleDLModelHandleDLModelHandleDLModelHandledlmodel_handle.

A deep learning model in HALCON mainly consists of a directed acyclic graph that defines the networks architecture. Further components of a deep learning model in HALCON are parameters as 'class_names'"class_names""class_names""class_names""class_names""class_names", 'class_ids'"class_ids""class_ids""class_ids""class_ids""class_ids", and many others, or hyperparameters that are needed to train a model, as for example the 'learning_rate'"learning_rate""learning_rate""learning_rate""learning_rate""learning_rate". While parameters and hyperparameters can be set after creation of the model using set_dl_model_paramset_dl_model_paramSetDlModelParamSetDlModelParamSetDlModelParamset_dl_model_param, the model itself can only be created using create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelCreateDlModelcreate_dl_model if its network architecture is given in form of a graph.

To build a graph that defines the models network architecture, one needs to put together the networks layers. In general, a graph starts with an input layer. A subsequent layer that follows after the input layer uses the input layer as feeding layer, and the new layer itself might be used as a feeding layer for the next layer, and so on. This is repeated until the graphs output layers (e.g., softmax or loss layers) are appended to the graph. To create a layer, use its specified creation operator, e.g., an input layer is created using create_dl_layer_inputcreate_dl_layer_inputCreateDlLayerInputCreateDlLayerInputCreateDlLayerInputcreate_dl_layer_input, a convolution layer is created using create_dl_layer_convolutioncreate_dl_layer_convolutionCreateDlLayerConvolutionCreateDlLayerConvolutionCreateDlLayerConvolutioncreate_dl_layer_convolution, and so on.

When the graph is defined, a model can be created using create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelCreateDlModelcreate_dl_model by passing over the graphs output layer handles in OutputLayersOutputLayersOutputLayersOutputLayersoutputLayersoutput_layers. Note that the output layer handles save all other layers that directly or indirectly serve as feeding input layers for the output layers during their creation. This means that the output layer handles keep the whole network architecture necessary for the creation of the model using create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelCreateDlModelcreate_dl_model.

The type of the created model, hence the task the model is designed for (classification, object detection, segmentation), is only given by the networks architecture. However, if the networks architecture allows it, the type of the model, 'type'"type""type""type""type""type", can be set using set_dl_model_paramset_dl_model_paramSetDlModelParamSetDlModelParamSetDlModelParamset_dl_model_param. A specified model type allows a more user friendly usage in the HALCON deep learning workflow. Supported types are:

'generic'"generic""generic""generic""generic""generic":

This is the default model type. The task the model's neuronal network can solve is defined by its architecture. When apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelApplyDlModelapply_dl_model is applied for inference, the operator returns the activations of the output layers. To train the model using train_dl_model_batchtrain_dl_model_batchTrainDlModelBatchTrainDlModelBatchTrainDlModelBatchtrain_dl_model_batch, the underlying graph requires loss layers.

'classification'"classification""classification""classification""classification""classification":

The model is specified for classification and all layers required for training the model are adapted to the model. When apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelApplyDlModelapply_dl_model is applied for inference, the output is adapted according to the type, see apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelApplyDlModelapply_dl_model for more details. See Deep Learning / Classification for further information.

In addition, the operator gen_dl_model_heatmapgen_dl_model_heatmapGenDlModelHeatmapGenDlModelHeatmapGenDlModelHeatmapgen_dl_model_heatmap can be used to display the models heatmap.

'detection'"detection""detection""detection""detection""detection":

The model is specified for object detection and instance segmentation and all layers and anchors required for training the model are adapted to the model. When apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelApplyDlModelapply_dl_model is applied for inference, the output is adapted according to the type, see apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelApplyDlModelapply_dl_model for more details. See Deep Learning / Object Detection and Instance Segmentation for further information.

'segmentation'"segmentation""segmentation""segmentation""segmentation""segmentation":

The model is specified for semantic segmentation or edge extraction respectively and all layers required for training the model are adapted to the model. When apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelApplyDlModelapply_dl_model is applied for inference, the output is adapted according to the type, see apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelApplyDlModelapply_dl_model for more details. See Deep Learning / Semantic Segmentation and Edge Extraction for further information.

Furthermore, many deep learning procedures provide more functionality for the model if its type is set. As an example, dev_display_dl_data can be used to display the inferred results more nicely.

Note that setting a model type requires that the graph fulfills certain structure conditions. We recommend to follow the architecture of our delivered neuronal networks if the model type should be set to one of these types.

Execution Information

This operator returns a handle. Note that the state of an instance of this handle type may be changed by specific operators even though the handle is used as an input parameter by those operators.

Parameters

OutputLayersOutputLayersOutputLayersOutputLayersoutputLayersoutput_layers (input_control)  dl_layer(-array) HDlLayer, HTupleMaybeSequence[HHandle]HTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Output layers of the graph.

DLModelHandleDLModelHandleDLModelHandleDLModelHandleDLModelHandledlmodel_handle (output_control)  dl_model HDlModel, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Handle of the deep learning model.

Result

If the parameters are valid, the operator create_dl_modelcreate_dl_modelCreateDlModelCreateDlModelCreateDlModelcreate_dl_model returns the value 2 ( H_MSG_TRUE) . If necessary, an exception is raised.

Possible Predecessors

create_dl_layer_softmaxcreate_dl_layer_softmaxCreateDlLayerSoftmaxCreateDlLayerSoftmaxCreateDlLayerSoftmaxcreate_dl_layer_softmax, create_dl_layer_loss_cross_entropycreate_dl_layer_loss_cross_entropyCreateDlLayerLossCrossEntropyCreateDlLayerLossCrossEntropyCreateDlLayerLossCrossEntropycreate_dl_layer_loss_cross_entropy, create_dl_layer_loss_focalcreate_dl_layer_loss_focalCreateDlLayerLossFocalCreateDlLayerLossFocalCreateDlLayerLossFocalcreate_dl_layer_loss_focal, create_dl_layer_loss_hubercreate_dl_layer_loss_huberCreateDlLayerLossHuberCreateDlLayerLossHuberCreateDlLayerLossHubercreate_dl_layer_loss_huber

Possible Successors

set_dl_model_paramset_dl_model_paramSetDlModelParamSetDlModelParamSetDlModelParamset_dl_model_param

Module

Deep Learning Training