*程序功能:读取onnx模型并推理
dev_update_off()
dev_close_window ()
read_dl_model ('squeezenet.onnx', DLModelHandle)
set_dl_model_param (DLModelHandle, 'type', 'classification')
get_dl_model_param(DLModelHandle, 'image_dimensions', ImageDimensions)
get_dl_model_param(DLModelHandle, 'class_names', ClassNames)
get_dl_model_param(DLModelHandle, 'class_ids', ClassIds)
set_dl_model_param (DLModelHandle, 'runtime_init', 'immediately')
dev_open_window(0, 0, 600, 400, 'black', WindowHandle)
set_font(WindowHandle, 'Microsoft YaHei UI-Bold-36')
read_image (Image, 'cat.jpg')
zoom_image_size (Image, ImagePreprocessedByte, ImageDimensions[0], ImageDimensions[1], 'constant')
convert_image_type (ImagePreprocessedByte, ImagePreprocessed, 'real')
scale_image (ImagePreprocessed, ImagePreprocessed, 1, -127)
create_dict (DLSample)
set_dict_object (ImagePreprocessed, DLSample, 'image')
apply_dl_model (DLModelHandle, DLSample, [], DLResult)
get_dict_tuple (DLResult, 'classification_confidences', Confidences)
get_dict_tuple (DLResult, 'classification_class_names', PredictClasses)
tuple_max (Confidences, Max)
tuple_find (Confidences, Max, IndexMax)
dev_clear_window ()
dev_display(Image)
Text := PredictClasses[IndexMax] + ', ' + Max$'.2f'
dev_disp_text (Text, 'window', 'top', 'left', 'red', 'box', 'false')