The hb_eval_preprocess Tool

The hb_eval_preprocess tool is used for preprocessing image data on x86 system.

Preprocessing refers to certain image data operations before being fed into the model, e.g., image resizing, image cropping, image padding, etc.

The basic flow of the hb_eval_preprocess tool to preprocess an image and generate a binary file is shown below:

hb_eval_preprocess_tool

Support Range

The board-side model is only supported by the AIbenchmark PTQ sample model, whose model is included:

mobilenetv1, mobilenetv2, resnet50, googlenet, efficientnet_lite0, efficientnet_lite1, efficientnet_lite2, efficientnet_lite3, efficientnet_lite4, vargconvnet, efficientnasnet_m, efficientnasnet_s, resnet18, yolov2_darknet19, yolov3_darknet53, yolov5x、ssd_mobilenetv1, centernet_resnet101, yolov3_vargdarknet, deeplabv3plus_efficientnetb0, fastscnn_efficientnetb0, deeplabv3plus_efficientnetm1, deeplabv3plus_efficientnetm2.

Usage

Usage: hb_eval_preprocess [OPTIONS] Example: hb_eval_preprocess -m mobilenetv1 -i ./files Options: -h, --help Show this message and exit. --version Show the version and exit. -m, --model_name Input model name. [required] [mobilenetv1|mobilenetv2|resnet50|googlenet|efficientnet_lite0|efficientnet_lite1| efficientnet_lite2|efficientnet_lite3|efficientnet_lite4|vargconvnet|efficientnasnet_m| efficientnasnet_s|resnet18|yolov2_darknet19|yolov3_darknet53|yolov5x|ssd_mobilenetv1| centernet_resnet101|yolov3_vargdarknet|deeplabv3plus_efficientnetb0|fastscnn_efficientnetb0| deeplabv3plus_efficientnetm1|deeplabv3plus_efficientnetm2] -i, --image_dir TEXT Input image dir. [required] -o, --output_dir TEXT Output dir. -v, --val_txt TEXT

Parameters Introduction

Parameter NameParameter Description
-h, --helpDisplay help information and exit.
--versionDisplay version information and exit.
-m, --model_nameSpecify the model name. You can use the hb_eval_preprocess --help command to see supported models.
-i, --image_dirSpecify the path of input images.
-o, --output_dirSpecify the output path.
-v, --val_txtSpecify the name of the image file required by the evaluation. The preprocessing will use these names to generate images.

Usage Example

Taking the resnet50 model as an example, you can use the following command to preprocess the image:

hb_eval_preprocess -m resnet50 -i ./files -o ./output

Output Contents

The hb_eval_preprocess tool will generate binary image files in the directory specified by the --output_dir parameter.

Hint

More application samples of the hb_eval_preprocess tool in the accuracy evaluations of on-board models can be found in Data Pre-process.