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_inferenceOptimizeDlModelForInferenceOptimizeDlModelForInferenceoptimize_dl_model_for_inference optimiert das
Eingabe-Modell DLModelHandleDLModelHandleDLModelHandleDLModelHandledlmodel_handle für die Inferenz auf der Einheit
DLDeviceHandleDLDeviceHandleDLDeviceHandleDLDeviceHandledldevice_handle und gibt das optimierte Modell
in DLModelHandleConvertedDLModelHandleConvertedDLModelHandleConvertedDLModelHandleConverteddlmodel_handle_converted zurück.
Dieser Operator hat zwei unterschiedliche Funktionalitäten:
Das Casten der Modell-Präzision in PrecisionPrecisionPrecisionprecisionprecision und Kalibrieren
des Modells basierend auf den gegebenen DLSamplesDLSamplesDLSamplesDLSamplesdlsamples.
Zusätzlich kann in beiden Fällen die Modellarchitektur für das
DLDeviceHandleDLDeviceHandleDLDeviceHandleDLDeviceHandledldevice_handle optimiert werden.
Der Parameter DLDeviceHandleDLDeviceHandleDLDeviceHandleDLDeviceHandledldevice_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_paramGetDlDeviceParamGetDlDeviceParamget_dl_device_param mit '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_inferenceOptimizeDlModelForInferenceOptimizeDlModelForInferenceoptimize_dl_model_for_inference
wird für das Ausgabe-Modell DLModelHandleConvertedDLModelHandleConvertedDLModelHandleConvertedDLModelHandleConverteddlmodel_handle_converted der Parameter
'precision_is_converted'"precision_is_converted""precision_is_converted""precision_is_converted""precision_is_converted" auf 'true'"true""true""true""true" gesetzt.
Zusätzlich wird die Deep-Learning-Einheit automatisch für das Modell gesetzt,
falls sie die angefragte Genauigkeit PrecisionPrecisionPrecisionprecisionprecision unterstützt.
Welche Genauigkeiten die Einheit unterstützt, kann über
get_dl_device_paramget_dl_device_paramGetDlDeviceParamGetDlDeviceParamget_dl_device_param mit 'precisions'"precisions""precisions""precisions""precisions" ermittelt
werden.
Der Parameter PrecisionPrecisionPrecisionprecisionprecision gibt die Genauigkeit an, in die das Modell
umgerechnet werden soll. Standardmäßig haben Modelle, die von HALCON
geliefert werden die PrecisionPrecisionPrecisionprecisionprecision 'float32'"float32""float32""float32""float32".
Die folgenden Werte werden für PrecisionPrecisionPrecisionprecisionprecision unterstützt:
-
'float32'"float32""float32""float32""float32"
-
'float16'"float16""float16""float16""float16"
-
'int8'"int8""int8""int8""int8"
Der Parameter DLSamplesDLSamplesDLSamplesDLSamplesdlsamples 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
DLSamplesDLSamplesDLSamplesDLSamplesdlsamples ein leeres Tupel übergeben werden.
Der Parameter GenParamGenParamGenParamgenParamgen_param legt weitere, Einheitenspezifische
Parameter und deren Werte fest.
Welche Parameter für das gegebene DLDeviceHandleDLDeviceHandleDLDeviceHandleDLDeviceHandledldevice_handle
in GenParamGenParamGenParamgenParamgen_param zu setzen sind sowie deren Defaultwerte,
kann über den Operator get_dl_device_paramget_dl_device_paramGetDlDeviceParamGetDlDeviceParamget_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" abgefragt werden.
Beachte, gewisse Einheiten erwarten auch nur ein leeres Dictionary.
Der Parameter ConversionReportConversionReportConversionReportconversionReportconversion_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
DLModelHandleConvertedDLModelHandleConvertedDLModelHandleConvertedDLModelHandleConverteddlmodel_handle_converted gesetzt werden, welche die Modellarchitektur
nicht verändern. Für set_dl_model_paramset_dl_model_paramSetDlModelParamSetDlModelParamset_dl_model_param handelt es sich hierbei um
die folgenden Parameter:
-
'Any': 'device'"device""device""device""device", 'meta_data'"meta_data""meta_data""meta_data""meta_data", 'runtime'"runtime""runtime""runtime""runtime"
-
'anomaly_detection': '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"
-
'ocr_detection': '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_word_score'"min_word_score""min_word_score""min_word_score""min_word_score", 'orientation'"orientation""orientation""orientation""orientation",
'sort_by_line'"sort_by_line""sort_by_line""sort_by_line""sort_by_line", 'tiling'"tiling""tiling""tiling""tiling",
'tiling_overlap'"tiling_overlap""tiling_overlap""tiling_overlap""tiling_overlap"
-
'ocr_recognition': 'alphabet'"alphabet""alphabet""alphabet""alphabet", 'alphabet_internal'"alphabet_internal""alphabet_internal""alphabet_internal""alphabet_internal",
'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"
-
'detection': '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_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",
'min_confidence'"min_confidence""min_confidence""min_confidence""min_confidence"
-
'segmentation': 'class_names'"class_names""class_names""class_names""class_names"
Für set_deep_ocr_paramset_deep_ocr_paramSetDeepOcrParamSetDeepOcrParamset_deep_ocr_param handelt es sich um die folgenden Parameter:
-
'device'"device""device""device""device", '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_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_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_tiling'"detection_tiling""detection_tiling""detection_tiling""detection_tiling", '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_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"
Für set_deep_counting_model_paramset_deep_counting_model_paramSetDeepCountingModelParamSetDeepCountingModelParamset_deep_counting_model_param handelt es sich um die folgenden
Parameter:
-
'device'"device""device""device""device"
-
'max_overlap'"max_overlap""max_overlap""max_overlap""max_overlap", 'min_score'"min_score""min_score""min_score""min_score"
Es kann nur das AI
2-Interface als 'device'"device""device""device""device" oder '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
DLModelHandleDLModelHandleDLModelHandleDLModelHandledlmodel_handle (input_control) dl_model → HDlModel, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Eingabe-Modell.
DLDeviceHandleDLDeviceHandleDLDeviceHandleDLDeviceHandledldevice_handle (input_control) dl_device(-array) → HDlDevice, HTupleMaybeSequence[HHandle]HTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Einheit-Handle, das für die Optimierung verwendet wird.
PrecisionPrecisionPrecisionprecisionprecision (input_control) string → HTuplestrHTupleHtuple (string) (string) (HString) (char*)
Präzision, in die das Modell konvertiert werden soll.
DLSamplesDLSamplesDLSamplesDLSamplesdlsamples (input_control) dict-array → HDict, HTupleSequence[HHandle]HTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Samples, die für die Optimierung benötigt werden.
GenParamGenParamGenParamgenParamgen_param (input_control) dict → HDict, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Parameter Dictionary für Optimierung.
DLModelHandleConvertedDLModelHandleConvertedDLModelHandleConvertedDLModelHandleConverteddlmodel_handle_converted (output_control) dl_model → HDlModel, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Ausgabe-Modell mit neuer Präzision.
ConversionReportConversionReportConversionReportconversionReportconversion_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_inferenceOptimizeDlModelForInferenceOptimizeDlModelForInferenceoptimize_dl_model_for_inference den Wert 2 (
H_MSG_TRUE)
. Gegebenenfalls wird eine
Fehlerbehandlung durchgeführt.
Vorgänger
train_dl_model_batchtrain_dl_model_batchTrainDlModelBatchTrainDlModelBatchtrain_dl_model_batch,
query_available_dl_devicesquery_available_dl_devicesQueryAvailableDlDevicesQueryAvailableDlDevicesquery_available_dl_devices
Nachfolger
set_dl_model_paramset_dl_model_paramSetDlModelParamSetDlModelParamset_dl_model_param,
apply_dl_modelapply_dl_modelApplyDlModelApplyDlModelapply_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