使用TVM自动生成模型部署项目-校准数据集格式

acewalter
Posts: 3
Joined: Sun Jan 07, 2024 7:47 pm

使用TVM自动生成模型部署项目-校准数据集格式

Postby acewalter » Sun Jan 14, 2024 6:18 pm

我在使用TVM量化MOVENET模型时出现了这个问题

CMD: python esp_quantize_onnx.py --input_model ./movenet_singlepose_lightning_4_opt.onnx --output_model ./model_quant.onnx --calibrate_dataset ./test_dataset.npy

Traceback (most recent call last):
File "esp_quantize_onnx.py", line 71, in <module>
main(args.input_model, args.output_model, args.calibrate_dataset, args.per_channel)
File "esp_quantize_onnx.py", line 33, in main
calibration_dataset_path, input_model_path
File "esp_quantize_onnx.py", line 15, in __init__
self.calib_data_list = np.load(calibration_image_npy)
File "D:\anaconda\envs\espdlTool\lib\site-packages\numpy\lib\npyio.py", line 441, in load
pickle_kwargs=pickle_kwargs)
File "D:\anaconda\envs\espdlTool\lib\site-packages\numpy\lib\format.py", line 743, in read_array
raise ValueError("Object arrays cannot be loaded when "
ValueError: Object arrays cannot be loaded when allow_pickle=False


我把从Tensflow 上下载的数据集的一部分转换成了Numpy格式的文件作为校准数据输入,这个是说明我的转换方式有问题吗?
Snipaste_2024-01-15_02-13-10.png
我看了https://zhuanlan.zhihu.com/p/590495368这个知乎的教程,里面的数据集文件,是用pickle文件保存的,我把它们用plt画出来也看到了图片和标签是一一对应的,向这种标签多信息多的,csv文件想要和图片组合成可以使用的数据集有没有什么明确的格式,或者例子呢,谢谢

BlueSkyB
Posts: 4
Joined: Tue Nov 28, 2023 3:01 am

Re: 使用TVM自动生成模型部署项目-校准数据集格式

Postby BlueSkyB » Tue Jan 16, 2024 6:33 am

数据集需要numpy格式,可以检查下数据集是否还是pickle。

https://docs.espressif.com/projects/esp ... -the-model
中有对校准数据集格式作说明:

"Create an input data reader: First, an input data reader will be created to read the calibration data from the data source. The dataset used for calibration should be saved as a NumPy array file. It contains a collection of input images. For example, the input size of model.onnx is [32, 32, 3], and calibe_images.npy stores the data of 500 calibration images with a shape of [500, 32, 32, 3]."

PTQ量化校准过程中,只使用数据即可,不用标签。
对于脚本具体的处理方式,可以查看esp-dl中的 "esp-dl/tools/tvm/esp_quantize_onnx.py" 的代码实现。

acewalter
Posts: 3
Joined: Sun Jan 07, 2024 7:47 pm

Re: 使用TVM自动生成模型部署项目-校准数据集格式

Postby acewalter » Tue Jan 16, 2024 9:03 pm

感谢你的回复,更换图片数组后可以正常量化了,但量化完的模型在生成工程时出现如下错误
Snipaste_2024-01-17_04-47-57.png
Snipaste_2024-01-17_04-47-57.png (122.5 KiB) Viewed 21540 times
Snipaste_2024-01-17_04-45-47.png
Snipaste_2024-01-17_04-45-47.png (13.68 KiB) Viewed 21540 times
这是详细log:
err_log.txt
(27.57 KiB) Downloaded 76 times
我使用的模型是这个https://www.kaggle.com/models/google/movenet/fr ... 成的ONNX格式模型
Inputs
A frame of video or an image, represented as an float32 tensor of shape: 192x192x3. Channels order: RGB with values in [0, 255].

Outputs
A float32 tensor of shape [1, 1, 17, 3].

这个报错是和模型有关吗,我使用.pb的模型预处理之后直接生成工程是成功的但是编译的时候会报错好像是全局变量占用的空间太大region `dram0_0_seg' overflowed by 6857832 bytes

Who is online

Users browsing this forum: No registered users and 70 guests