optimize_dl_model_for_inferenceT_optimize_dl_model_for_inferenceOptimizeDlModelForInferenceOptimizeDlModelForInferenceoptimize_dl_model_for_inference (Operator)
Name
optimize_dl_model_for_inferenceT_optimize_dl_model_for_inferenceOptimizeDlModelForInferenceOptimizeDlModelForInferenceoptimize_dl_model_for_inference — Optimiere ein Modell für die Inferenz auf einer Einheit über die AI
2-Schnittstelle.
Signatur
void OptimizeDlModelForInference(const HTuple& DLModelHandle, const HTuple& DLDeviceHandle, const HTuple& Precision, const HTuple& DLSamples, const HTuple& GenParam, HTuple* DLModelHandleConverted, HTuple* ConversionReport)
HDlModel HDlModel::OptimizeDlModelForInference(const HDlDeviceArray& DLDeviceHandle, const HString& Precision, const HDictArray& DLSamples, const HDict& GenParam, HDict* ConversionReport) const
HDlModel HDlModel::OptimizeDlModelForInference(const HDlDevice& DLDeviceHandle, const HString& Precision, const HDictArray& DLSamples, const HDict& GenParam, HDict* ConversionReport) const
HDlModel HDlModel::OptimizeDlModelForInference(const HDlDevice& DLDeviceHandle, const char* Precision, const HDictArray& DLSamples, const HDict& GenParam, HDict* ConversionReport) const
HDlModel HDlModel::OptimizeDlModelForInference(const HDlDevice& DLDeviceHandle, const wchar_t* Precision, const HDictArray& DLSamples, const HDict& GenParam, HDict* ConversionReport) const
(
Nur Windows)
static void HOperatorSet.OptimizeDlModelForInference(HTuple DLModelHandle, HTuple DLDeviceHandle, HTuple precision, HTuple DLSamples, HTuple genParam, out HTuple DLModelHandleConverted, out HTuple conversionReport)
HDlModel HDlModel.OptimizeDlModelForInference(HDlDevice[] DLDeviceHandle, string precision, HDict[] DLSamples, HDict genParam, out HDict conversionReport)
HDlModel HDlModel.OptimizeDlModelForInference(HDlDevice DLDeviceHandle, string precision, HDict[] DLSamples, HDict genParam, out HDict conversionReport)
Beschreibung
Der Operator optimize_dl_model_for_inferenceoptimize_dl_model_for_inferenceOptimizeDlModelForInferenceOptimizeDlModelForInferenceOptimizeDlModelForInferenceoptimize_dl_model_for_inference optimiert das
Eingabe-Modell DLModelHandleDLModelHandleDLModelHandleDLModelHandleDLModelHandledlmodel_handle für die Inferenz auf der Einheit
DLDeviceHandleDLDeviceHandleDLDeviceHandleDLDeviceHandleDLDeviceHandledldevice_handle und gibt das optimierte Modell
in DLModelHandleConvertedDLModelHandleConvertedDLModelHandleConvertedDLModelHandleConvertedDLModelHandleConverteddlmodel_handle_converted zurück.
Dieser Operator hat zwei unterschiedliche Funktionalitäten:
Das Casten der Modell-Präzision in PrecisionPrecisionPrecisionPrecisionprecisionprecision und Kalibrieren
des Modells basierend auf den gegebenen DLSamplesDLSamplesDLSamplesDLSamplesDLSamplesdlsamples.
Zusätzlich kann in beiden Fällen die Modellarchitektur für das
DLDeviceHandleDLDeviceHandleDLDeviceHandleDLDeviceHandleDLDeviceHandledldevice_handle optimiert werden.
Der Parameter DLDeviceHandleDLDeviceHandleDLDeviceHandleDLDeviceHandleDLDeviceHandledldevice_handle gibt die Deep-Learning-Einheit an,
für welche das Modell optimiert wird.
Ob die Einheit die Optimierung unterstützt, kann über
get_dl_device_paramget_dl_device_paramGetDlDeviceParamGetDlDeviceParamGetDlDeviceParamget_dl_device_param mit 'conversion_supported'"conversion_supported""conversion_supported""conversion_supported""conversion_supported""conversion_supported" ermittelt
werden.
Nach einer erfolgreichen Ausführung von optimize_dl_model_for_inferenceoptimize_dl_model_for_inferenceOptimizeDlModelForInferenceOptimizeDlModelForInferenceOptimizeDlModelForInferenceoptimize_dl_model_for_inference
wird für das Ausgabe-Modell DLModelHandleConvertedDLModelHandleConvertedDLModelHandleConvertedDLModelHandleConvertedDLModelHandleConverteddlmodel_handle_converted der Parameter
'precision_is_converted'"precision_is_converted""precision_is_converted""precision_is_converted""precision_is_converted""precision_is_converted" auf 'true'"true""true""true""true""true" gesetzt.
Zusätzlich wird die Deep-Learning-Einheit automatisch für das Modell gesetzt,
falls sie die angefragte Genauigkeit PrecisionPrecisionPrecisionPrecisionprecisionprecision unterstützt.
Welche Genauigkeiten die Einheit unterstützt, kann über
get_dl_device_paramget_dl_device_paramGetDlDeviceParamGetDlDeviceParamGetDlDeviceParamget_dl_device_param mit 'precisions'"precisions""precisions""precisions""precisions""precisions" ermittelt
werden.
Der Parameter PrecisionPrecisionPrecisionPrecisionprecisionprecision gibt die Genauigkeit an, in die das Modell
umgerechnet werden soll. Standardmäßig haben Modelle, die von HALCON
geliefert werden die PrecisionPrecisionPrecisionPrecisionprecisionprecision 'float32'"float32""float32""float32""float32""float32".
Die folgenden Werte werden für PrecisionPrecisionPrecisionPrecisionprecisionprecision unterstützt:
-
'float32'"float32""float32""float32""float32""float32"
-
'float16'"float16""float16""float16""float16""float16"
-
'int8'"int8""int8""int8""int8""int8"
Der Parameter DLSamplesDLSamplesDLSamplesDLSamplesDLSamplesdlsamples gibt die Samples an, auf welchen
die Kalibrierung durchgeführt wird.
Folglich sollten sie repräsentativ sein.
Es wird empfohlen, sie aus dem Trainingssplit bereitzustellen.
Für die meisten Anwendungen reichen 10-20 Samples pro Klasse für
gute Ergebnisse.
Beachten Sie, dass die Samples für einen reinen Cast-Prozess
nicht benötigt werden. In diesem Fall kann für
DLSamplesDLSamplesDLSamplesDLSamplesDLSamplesdlsamples ein leeres Tupel übergeben werden.
Der Parameter GenParamGenParamGenParamGenParamgenParamgen_param legt weitere, Einheitenspezifische
Parameter und deren Werte fest.
Welche Parameter für das gegebene DLDeviceHandleDLDeviceHandleDLDeviceHandleDLDeviceHandleDLDeviceHandledldevice_handle
in GenParamGenParamGenParamGenParamgenParamgen_param zu setzen sind sowie deren Defaultwerte,
kann über den Operator get_dl_device_paramget_dl_device_paramGetDlDeviceParamGetDlDeviceParamGetDlDeviceParamget_dl_device_param mit dem Parameter
'optimize_for_inference_params'"optimize_for_inference_params""optimize_for_inference_params""optimize_for_inference_params""optimize_for_inference_params""optimize_for_inference_params" abgefragt werden.
Beachte, gewisse Einheiten erwarten auch nur ein leeres Dictionary.
Der Parameter ConversionReportConversionReportConversionReportConversionReportconversionReportconversion_report gibt einen Report-Dictionary
mit Informationen zur Konvertierung zurück.
Achtung
Dieser Operator kann nur über ein AI
2-Interface verwendet werden.
Außerdem können nach der Konvertierung ausschließlich Parameter für
DLModelHandleConvertedDLModelHandleConvertedDLModelHandleConvertedDLModelHandleConvertedDLModelHandleConverteddlmodel_handle_converted gesetzt werden, welche die Modellarchitektur
nicht verändern. Für set_dl_model_paramset_dl_model_paramSetDlModelParamSetDlModelParamSetDlModelParamset_dl_model_param handelt es sich hierbei um
die folgenden Parameter:
-
'Any': 'device'"device""device""device""device""device", 'runtime'"runtime""runtime""runtime""runtime""runtime"
-
'anomaly_detection': 'standard_deviation_factor'"standard_deviation_factor""standard_deviation_factor""standard_deviation_factor""standard_deviation_factor""standard_deviation_factor"
-
'classification': 'class_names'"class_names""class_names""class_names""class_names""class_names"
-
'ocr_detection': 'min_character_score'"min_character_score""min_character_score""min_character_score""min_character_score""min_character_score", 'min_link_score'"min_link_score""min_link_score""min_link_score""min_link_score""min_link_score",
'min_word_score'"min_word_score""min_word_score""min_word_score""min_word_score""min_word_score", 'orientation'"orientation""orientation""orientation""orientation""orientation",
'sort_by_line'"sort_by_line""sort_by_line""sort_by_line""sort_by_line""sort_by_line", 'tiling'"tiling""tiling""tiling""tiling""tiling",
'tiling_overlap'"tiling_overlap""tiling_overlap""tiling_overlap""tiling_overlap""tiling_overlap"
-
'ocr_recognition': 'alphabet'"alphabet""alphabet""alphabet""alphabet""alphabet", 'alphabet_internal'"alphabet_internal""alphabet_internal""alphabet_internal""alphabet_internal""alphabet_internal",
'alphabet_mapping'"alphabet_mapping""alphabet_mapping""alphabet_mapping""alphabet_mapping""alphabet_mapping"
-
'gc_anomaly_detection': 'anomaly_score_tolerance'"anomaly_score_tolerance""anomaly_score_tolerance""anomaly_score_tolerance""anomaly_score_tolerance""anomaly_score_tolerance"
-
'detection': 'class_names'"class_names""class_names""class_names""class_names""class_names", 'max_num_detections'"max_num_detections""max_num_detections""max_num_detections""max_num_detections""max_num_detections",
'max_overlap'"max_overlap""max_overlap""max_overlap""max_overlap""max_overlap", 'max_overlap_class_agnostic'"max_overlap_class_agnostic""max_overlap_class_agnostic""max_overlap_class_agnostic""max_overlap_class_agnostic""max_overlap_class_agnostic",
'min_confidence'"min_confidence""min_confidence""min_confidence""min_confidence""min_confidence"
-
'segmentation': 'class_names'"class_names""class_names""class_names""class_names""class_names"
Für set_deep_ocr_paramset_deep_ocr_paramSetDeepOcrParamSetDeepOcrParamSetDeepOcrParamset_deep_ocr_param handelt es sich um die folgenden Parameter:
-
'device'"device""device""device""device""device", 'runtime'"runtime""runtime""runtime""runtime""runtime"
-
'detection_min_character_score'"detection_min_character_score""detection_min_character_score""detection_min_character_score""detection_min_character_score""detection_min_character_score",
'detection_min_link_score'"detection_min_link_score""detection_min_link_score""detection_min_link_score""detection_min_link_score""detection_min_link_score",
'detection_min_word_score'"detection_min_word_score""detection_min_word_score""detection_min_word_score""detection_min_word_score""detection_min_word_score",
-
'detection_orientation'"detection_orientation""detection_orientation""detection_orientation""detection_orientation""detection_orientation",
'detection_sort_by_line'"detection_sort_by_line""detection_sort_by_line""detection_sort_by_line""detection_sort_by_line""detection_sort_by_line",
-
'detection_tiling'"detection_tiling""detection_tiling""detection_tiling""detection_tiling""detection_tiling", 'detection_tiling_overlap'"detection_tiling_overlap""detection_tiling_overlap""detection_tiling_overlap""detection_tiling_overlap""detection_tiling_overlap"
-
'recognition_alphabet'"recognition_alphabet""recognition_alphabet""recognition_alphabet""recognition_alphabet""recognition_alphabet",
'recognition_alphabet_internal'"recognition_alphabet_internal""recognition_alphabet_internal""recognition_alphabet_internal""recognition_alphabet_internal""recognition_alphabet_internal",
'recognition_alphabet_mapping'"recognition_alphabet_mapping""recognition_alphabet_mapping""recognition_alphabet_mapping""recognition_alphabet_mapping""recognition_alphabet_mapping"
Für set_deep_counting_model_paramset_deep_counting_model_paramSetDeepCountingModelParamSetDeepCountingModelParamSetDeepCountingModelParamset_deep_counting_model_param handelt es sich um die folgenden
Parameter:
-
'device'"device""device""device""device""device"
-
'max_overlap'"max_overlap""max_overlap""max_overlap""max_overlap""max_overlap", 'min_score'"min_score""min_score""min_score""min_score""min_score"
Es kann nur das AI
2-Interface als 'device'"device""device""device""device""device" oder 'runtime'"runtime""runtime""runtime""runtime""runtime"
gesetzt werden, mit dem das Modell optimiert worden ist.
Für die oben genannten Parameter können zusätzliche Restriktionen gelten, um
sicher zu stellen, dass die Modellarchitektur erhalten bleibt.
Ausführungsinformationen
- Multithreading-Typ: reentrant (läuft parallel zu nicht-exklusiven Operatoren).
- Multithreading-Bereich: global (kann von jedem Thread aufgerufen werden).
- Wird ohne Parallelisierung verarbeitet.
Parameter
DLModelHandleDLModelHandleDLModelHandleDLModelHandleDLModelHandledlmodel_handle (input_control) dl_model → HDlModel, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Eingabe-Modell.
DLDeviceHandleDLDeviceHandleDLDeviceHandleDLDeviceHandleDLDeviceHandledldevice_handle (input_control) dl_device(-array) → HDlDevice, HTupleMaybeSequence[HHandle]HTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Einheit-Handle, das für die Optimierung verwendet wird.
PrecisionPrecisionPrecisionPrecisionprecisionprecision (input_control) string → HTuplestrHTupleHtuple (string) (string) (HString) (char*)
Präzision, in die das Modell konvertiert werden soll.
DLSamplesDLSamplesDLSamplesDLSamplesDLSamplesdlsamples (input_control) dict-array → HDict, HTupleSequence[HHandle]HTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Samples, die für die Optimierung benötigt werden.
GenParamGenParamGenParamGenParamgenParamgen_param (input_control) dict → HDict, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Parameter Dictionary für Optimierung.
DLModelHandleConvertedDLModelHandleConvertedDLModelHandleConvertedDLModelHandleConvertedDLModelHandleConverteddlmodel_handle_converted (output_control) dl_model → HDlModel, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Ausgabe-Modell mit neuer Präzision.
ConversionReportConversionReportConversionReportConversionReportconversionReportconversion_report (output_control) dict → HDict, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Ausgabe-Report der Optimierung.
Ergebnis
Sind die Parameterwerte korrekt, dann liefert
optimize_dl_model_for_inferenceoptimize_dl_model_for_inferenceOptimizeDlModelForInferenceOptimizeDlModelForInferenceOptimizeDlModelForInferenceoptimize_dl_model_for_inference den Wert 2 (
H_MSG_TRUE)
. Gegebenenfalls wird eine
Fehlerbehandlung durchgeführt.
Vorgänger
train_dl_model_batchtrain_dl_model_batchTrainDlModelBatchTrainDlModelBatchTrainDlModelBatchtrain_dl_model_batch,
query_available_dl_devicesquery_available_dl_devicesQueryAvailableDlDevicesQueryAvailableDlDevicesQueryAvailableDlDevicesquery_available_dl_devices
Nachfolger
set_dl_model_paramset_dl_model_paramSetDlModelParamSetDlModelParamSetDlModelParamset_dl_model_param,
apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelApplyDlModelapply_dl_model
Modul
Foundation. Dieser Operator verwendet dynamische Lizenzierung (siehe ``Installation Guide''). Welches der folgenden Module benötigt wird hängt von der Anwendung des Operators ab:
3D Metrology, OCR/OCV, Matching, Deep Learning Inference