apply_dl_modelT_apply_dl_modelApplyDlModelApplyDlModelapply_dl_model (Operator)

Name

apply_dl_modelT_apply_dl_modelApplyDlModelApplyDlModelapply_dl_model — Anwenden des Deep Learning-basierten Netzwerkes zur Inferenz auf einer Menge an Bildern.

Signatur

apply_dl_model( : : DLModelHandle, DLSampleBatch, Outputs : DLResultBatch)

Herror T_apply_dl_model(const Htuple DLModelHandle, const Htuple DLSampleBatch, const Htuple Outputs, Htuple* DLResultBatch)

void ApplyDlModel(const HTuple& DLModelHandle, const HTuple& DLSampleBatch, const HTuple& Outputs, HTuple* DLResultBatch)

HDictArray HDlModel::ApplyDlModel(const HDictArray& DLSampleBatch, const HTuple& Outputs) const

static void HOperatorSet.ApplyDlModel(HTuple DLModelHandle, HTuple DLSampleBatch, HTuple outputs, out HTuple DLResultBatch)

HDict[] HDlModel.ApplyDlModel(HDict[] DLSampleBatch, HTuple outputs)

def apply_dl_model(dlmodel_handle: HHandle, dlsample_batch: Sequence[HHandle], outputs: Sequence[str]) -> Sequence[HHandle]

Beschreibung

apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelApplyDlModelapply_dl_model wendet das durch DLModelHandleDLModelHandleDLModelHandleDLModelHandleDLModelHandledlmodel_handle gegebene Deep Learning-basierte Netzwerk auf ein Batch von Eingabebildern an, die über das Tupel von Dictionaries DLSampleBatchDLSampleBatchDLSampleBatchDLSampleBatchDLSampleBatchdlsample_batch übergeben werden. Der Operator gibt DLResultBatchDLResultBatchDLResultBatchDLResultBatchDLResultBatchdlresult_batch zurück, ein Tupel mit einem Ergebnis-Dictionary DLResultDLResultDLResultDLResultDLResultdlresult pro Eingabebild.

Für weitere Informationen zum Konzept und den Dictionaries des Deep Learning-Modells in HALCON siehe das Kapitel Deep Learning / Modell.

Um das Netzwerk auf Bilder anwenden zu können, müssen diese über ein Tupel von Dictionaries DLSampleBatchDLSampleBatchDLSampleBatchDLSampleBatchDLSampleBatchdlsample_batch übergeben werden. Dabei bezieht sich jedes Dictionary auf ein einzelnes Bild. Mit Hilfe der Prozedur gen_dl_samples_from_images kann solch ein Dictionary passend erstellt werden. Das Tupel DLSampleBatchDLSampleBatchDLSampleBatchDLSampleBatchDLSampleBatchdlsample_batch kann eine beliebige Anzahl Dictionaries enthalten. Der Operator apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelApplyDlModelapply_dl_model verarbeitet stets einen Batch mit bis zu 'batch_size'"batch_size""batch_size""batch_size""batch_size""batch_size" Bildern simultan. Falls das Tupel mehr Bilder enthält, iteriert apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelApplyDlModelapply_dl_model intern über die notwendige Anzahl an Batches um alle Bilder zu verarbeiten. Für ein DLSampleBatchDLSampleBatchDLSampleBatchDLSampleBatchDLSampleBatchdlsample_batch mit weniger als 'batch_size'"batch_size""batch_size""batch_size""batch_size""batch_size" Bildern wird das Tupel zu einem vollen Batch aufgefüllt, was also bedeutet, dass die Laufzeit zur Verarbeitung eines solchen Batches unabhängig davon ist, ob dieser vollständig gefüllt ist oder nur ein einzelnes Bild enthält. Dies heißt auch, dass das Netzwerk stets den vollen Speicher benötigt, selbst wenn in einem Operatorenaufruf weniger als 'batch_size'"batch_size""batch_size""batch_size""batch_size""batch_size" Bilder verarbeitet werden sollen. Der aktuelle Wert von 'batch_size'"batch_size""batch_size""batch_size""batch_size""batch_size" kann mittels get_dl_model_paramget_dl_model_paramGetDlModelParamGetDlModelParamGetDlModelParamget_dl_model_param abgefragt werden.

Es ist zu beachten, dass die Bilder eventuell vorverarbeitet werden müssen um die die Netzwerkanforderungen zu erfüllen, bevor sie dem Operator apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelApplyDlModelapply_dl_model übergeben werden können. Mit get_dl_model_paramget_dl_model_paramGetDlModelParamGetDlModelParamGetDlModelParamget_dl_model_param können die aktuellen Anforderungen des Netzwerks wie z.B. die Bilddimensionen abgefragt werden. Die Prozedur preprocess_dl_dataset gibt eine Anleitung für die Implementierung dieser Vorverarbeitung.

Die Resultate werden in DLResultBatchDLResultBatchDLResultBatchDLResultBatchDLResultBatchdlresult_batch zurückgegeben, einem Tupel mit einem Dictionary DLResultDLResultDLResultDLResultDLResultdlresult für jedes Eingabebild. Für weitere Informationen zu den Ausgabe-Dictionaries DLResultBatchDLResultBatchDLResultBatchDLResultBatchDLResultBatchdlresult_batch und dessen Schlüssel siehe das Kapitel Deep Learning / Modell. In OutputsOutputsOutputsOutputsoutputsoutputs kann spezifiziert werden, welche Daten vom Netzwerk in den Ergebnis-Dictionaries DLResultBatchDLResultBatchDLResultBatchDLResultBatchDLResultBatchdlresult_batch ausgegeben werden. Dabei kann OutputsOutputsOutputsOutputsoutputsoutputs ein einzelner String, ein Tupel von Strings, oder ein leeres Tupel, mit dem alle möglichen Ausgaben abgerufen werden können, sein. Falls apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelApplyDlModelapply_dl_model über eine AI2-Schnittstelle genutzt wird, kann es notwendig sein, dass 'is_inference_output'"is_inference_output""is_inference_output""is_inference_output""is_inference_output""is_inference_output" = 'true'"true""true""true""true""true" für alle Layer in OutputsOutputsOutputsOutputsoutputsoutputs gesetzt werden muss, bevor das Modell für die AI2-Schnittstelle optimiert wird, siehe optimize_dl_model_for_inferenceoptimize_dl_model_for_inferenceOptimizeDlModelForInferenceOptimizeDlModelForInferenceOptimizeDlModelForInferenceoptimize_dl_model_for_inference und set_dl_model_layer_paramset_dl_model_layer_paramSetDlModelLayerParamSetDlModelLayerParamSetDlModelLayerParamset_dl_model_layer_param für Details dazu. Die Werte für OutputsOutputsOutputsOutputsoutputsoutputs sind abhängig vom Modelltyp des verwendeten Netzwerks:

Modell mit 'type'"type""type""type""type""type"='3d_gripping_point_detection'"3d_gripping_point_detection""3d_gripping_point_detection""3d_gripping_point_detection""3d_gripping_point_detection""3d_gripping_point_detection"

Modell mit 'type'"type""type""type""type""type"='anomaly_detection'"anomaly_detection""anomaly_detection""anomaly_detection""anomaly_detection""anomaly_detection"

Modell mit 'type'"type""type""type""type""type"='gc_anomaly_detection'"gc_anomaly_detection""gc_anomaly_detection""gc_anomaly_detection""gc_anomaly_detection""gc_anomaly_detection"

Für jeden Wert von OutputsOutputsOutputsOutputsoutputsoutputs enthält DLResultDLResultDLResultDLResultDLResultdlresult ein Bild, in dem jedes Pixel den Score des entsprechenden Pixels des Eingabebildes erhält. Zusätzlich enthält es einen Score für das Bild als Ganzes.

Modell mit 'type'"type""type""type""type""type"='classification'"classification""classification""classification""classification""classification"

Modell mit 'type'"type""type""type""type""type"='detection'"detection""detection""detection""detection""detection"

Modell mit 'type'"type""type""type""type""type"='ocr_recognition'"ocr_recognition""ocr_recognition""ocr_recognition""ocr_recognition""ocr_recognition"

Modell mit 'type'"type""type""type""type""type"='segmentation'"segmentation""segmentation""segmentation""segmentation""segmentation"

Achtung

Systemvoraussetzungen: Um diesen Operator auf der GPU auszuführen, indem 'device'"device""device""device""device""device" auf 'gpu'"gpu""gpu""gpu""gpu""gpu" gesetzt ist (siehe get_dl_model_paramget_dl_model_paramGetDlModelParamGetDlModelParamGetDlModelParamget_dl_model_param), werden cuDNN und cuBLAS benötigt. Für weitere Details wird auf den „Installation Guide“, Abschnitt „Requirements for Deep Learning and Deep-Learning-Based Methods“, verwiesen.

Ausführungsinformationen

Dieser Operator unterstützt Cancel-Timeouts und Interrupts.

Dieser Operator unterstützt Break-Timeouts und Interrupts.

Parameter

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

Handle des Deep Learning-Modells.

DLSampleBatchDLSampleBatchDLSampleBatchDLSampleBatchDLSampleBatchdlsample_batch (input_control)  dict-array HDict, HTupleSequence[HHandle]HTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Eingabedaten.

OutputsOutputsOutputsOutputsoutputsoutputs (input_control)  string-array HTupleSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Angeforderte Ausgabedaten.

Defaultwert: []

Werteliste: [], 'bboxhead2_prediction'"bboxhead2_prediction""bboxhead2_prediction""bboxhead2_prediction""bboxhead2_prediction""bboxhead2_prediction", 'classhead2_prediction'"classhead2_prediction""classhead2_prediction""classhead2_prediction""classhead2_prediction""classhead2_prediction", 'segmentation_confidence'"segmentation_confidence""segmentation_confidence""segmentation_confidence""segmentation_confidence""segmentation_confidence", 'segmentation_image'"segmentation_image""segmentation_image""segmentation_image""segmentation_image""segmentation_image"

DLResultBatchDLResultBatchDLResultBatchDLResultBatchDLResultBatchdlresult_batch (output_control)  dict-array HDict, HTupleSequence[HHandle]HTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Dictionary mit Ergebnisdaten.

Ergebnis

Sind die Parameterwerte korrekt, dann liefert apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelApplyDlModelapply_dl_model den Wert 2 (H_MSG_TRUE). Gegebenenfalls wird eine Fehlerbehandlung durchgeführt.

Vorgänger

read_dl_modelread_dl_modelReadDlModelReadDlModelReadDlModelread_dl_model, train_dl_model_batchtrain_dl_model_batchTrainDlModelBatchTrainDlModelBatchTrainDlModelBatchtrain_dl_model_batch, train_dl_model_anomaly_datasettrain_dl_model_anomaly_datasetTrainDlModelAnomalyDatasetTrainDlModelAnomalyDatasetTrainDlModelAnomalyDatasettrain_dl_model_anomaly_dataset, set_dl_model_paramset_dl_model_paramSetDlModelParamSetDlModelParamSetDlModelParamset_dl_model_param

Modul

Foundation. Dieser Operator verwendet dynamische Lizensierung (siehe ``Installation Guide''). Welches der folgenden Module benötigt wird hängt von der Anwendung des Operators ab:
3D Metrology, OCR/OCV, Deep Learning Inference