ClassesClasses | | Operators

read_dl_classifierread_dl_classifierReadDlClassifierReadDlClassifier (Operator)

Name

read_dl_classifierread_dl_classifierReadDlClassifierReadDlClassifier — Read a deep-learning-based classifier from a file.

Signature

read_dl_classifier( : : FileName : DLClassifierHandle)

Herror read_dl_classifier(const char* FileName, Hlong* DLClassifierHandle)

Herror T_read_dl_classifier(const Htuple FileName, Htuple* DLClassifierHandle)

void ReadDlClassifier(const HTuple& FileName, HTuple* DLClassifierHandle)

void HDlClassifier::HDlClassifier(const HString& FileName)

void HDlClassifier::HDlClassifier(const char* FileName)

void HDlClassifier::ReadDlClassifier(const HString& FileName)

void HDlClassifier::ReadDlClassifier(const char* FileName)

static void HOperatorSet.ReadDlClassifier(HTuple fileName, out HTuple DLClassifierHandle)

public HDlClassifier(string fileName)

void HDlClassifier.ReadDlClassifier(string fileName)

Description

The operator read_dl_classifierread_dl_classifierReadDlClassifierReadDlClassifierReadDlClassifier reads a neural network written by write_dl_classifierwrite_dl_classifierWriteDlClassifierWriteDlClassifierWriteDlClassifier.

HALCON provides pretrained neural networks. These neural networks are good starting points to train a custom classifier for image classification. They have been pretrained on a large image data set. The provided pretrained neural networks are:

'pretrained_dl_classifier_compact.hdl'"pretrained_dl_classifier_compact.hdl""pretrained_dl_classifier_compact.hdl""pretrained_dl_classifier_compact.hdl""pretrained_dl_classifier_compact.hdl":

This neural network is designed to be memory and runtime efficient.

This classifier expects a certain kind of input images. The respective parameters can be retrieved with get_dl_classifier_paramget_dl_classifier_paramGetDlClassifierParamGetDlClassifierParamGetDlClassifierParam:

'image_width': 224

'image_height': 224

'image_num_channels': 3

'image_range_min': -127

'image_range_max': 128

'pretrained_dl_classifier_enhanced.hdl'"pretrained_dl_classifier_enhanced.hdl""pretrained_dl_classifier_enhanced.hdl""pretrained_dl_classifier_enhanced.hdl""pretrained_dl_classifier_enhanced.hdl":

This neural network has more hidden layers than 'pretrained_dl_classifier_compact.hdl'"pretrained_dl_classifier_compact.hdl""pretrained_dl_classifier_compact.hdl""pretrained_dl_classifier_compact.hdl""pretrained_dl_classifier_compact.hdl" and is therefore assumed to be better suited for more complex classification tasks. But this comes at the cost of being more time and memory demanding. As a result, e.g. in comparison to the above compact network, the batch size has to be decreased network during the training, see set_dl_classifier_paramset_dl_classifier_paramSetDlClassifierParamSetDlClassifierParamSetDlClassifierParam.

This classifier expects a certain kind of input images. The respective parameters can be retrieved with get_dl_classifier_paramget_dl_classifier_paramGetDlClassifierParamGetDlClassifierParamGetDlClassifierParam:

'image_width': 224

'image_height': 224

'image_num_channels': 3

'image_range_min': -127

'image_range_max': 128

Every image that is fed into a network must be present according to the required parameters listed above. To adjust images accordingly, the procedure preprocess_dl_classifier_images is available.

If you want to apply the classifier to bigger or smaller images, you have to preprocess your images accordingly. For bigger images it might be useful to crop the important parts of the image first and then apply a zooming.

Typically it is easier, faster and better to retrain a pretrained classifier for a given classification problem. A pretrained classifier has already learned good general purpose features. To retrain the network for a custom problem, the new 'classes'"classes""classes""classes""classes" of the classifier have to be set with set_dl_classifier_paramset_dl_classifier_paramSetDlClassifierParamSetDlClassifierParamSetDlClassifierParam (see HDevelop example classify_pill_defects_deep_learning.hdev)

The neural network is loaded from the file FileNameFileNameFileNameFileNamefileName. This file is hereby searched in the directory ($HALCONROOT/dl/) as well as in the currently used directory.

Please note that the runtime specific parameter 'gpu'"gpu""gpu""gpu""gpu" of the classifier is not read from file. Instead it is initialized with its default value (see set_dl_classifier_paramset_dl_classifier_paramSetDlClassifierParamSetDlClassifierParamSetDlClassifierParam).

The default HALCON file extension for deep learning classifiers is '.hdl'".hdl"".hdl"".hdl"".hdl".

For an explanation of the concept of deep-learning-based classification see the introduction of chapter Deep Learning / Classification.

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

FileNameFileNameFileNameFileNamefileName (input_control)  filename.read HTupleHTupleHtuple (string) (string) (HString) (char*)

File name.

Default value: 'pretrained_dl_classifier_compact.hdl' "pretrained_dl_classifier_compact.hdl" "pretrained_dl_classifier_compact.hdl" "pretrained_dl_classifier_compact.hdl" "pretrained_dl_classifier_compact.hdl"

List of values: 'pretrained_dl_classifier_compact.hdl'"pretrained_dl_classifier_compact.hdl""pretrained_dl_classifier_compact.hdl""pretrained_dl_classifier_compact.hdl""pretrained_dl_classifier_compact.hdl", 'pretrained_dl_classifier_enhanced.hdl'"pretrained_dl_classifier_enhanced.hdl""pretrained_dl_classifier_enhanced.hdl""pretrained_dl_classifier_enhanced.hdl""pretrained_dl_classifier_enhanced.hdl"

File extension: .hdl

DLClassifierHandleDLClassifierHandleDLClassifierHandleDLClassifierHandleDLClassifierHandle (output_control)  dl_classifier HDlClassifier, HTupleHTupleHtuple (integer) (IntPtr) (Hlong) (Hlong)

Handle of the deep learning classifier.

Result

If the indicated file is available and the format is correct, the operator read_dl_classifierread_dl_classifierReadDlClassifierReadDlClassifierReadDlClassifier returns the value 2 (H_MSG_TRUE). Otherwise an exception will be raised.

Possible Successors

set_dl_classifier_paramset_dl_classifier_paramSetDlClassifierParamSetDlClassifierParamSetDlClassifierParam, get_dl_classifier_paramget_dl_classifier_paramGetDlClassifierParamGetDlClassifierParamGetDlClassifierParam, apply_dl_classifierapply_dl_classifierApplyDlClassifierApplyDlClassifierApplyDlClassifier, train_dl_classifier_batchtrain_dl_classifier_batchTrainDlClassifierBatchTrainDlClassifierBatchTrainDlClassifierBatch

Alternatives

read_class_mlpread_class_mlpReadClassMlpReadClassMlpReadClassMlp, read_class_svmread_class_svmReadClassSvmReadClassSvmReadClassSvm

Module

Deep Learning Inference


ClassesClasses | | Operators