PaddleSlim
PaddleSlim copied to clipboard
修改过的yolov5s模型如何使用paddleslim
请问修改过的yolov5s模型导出了onnx模型之后如何使用paddleslim,我这边会报错,自动化压缩工具ACT(Auto Compression Toolkit) Fail to generate inference model! Problem happend while export inference model from python code 'D:\pro\PaddleSlim-develop\best_infer\onnx2paddle_0\x2paddle_code.py';
===================Error Information=============== 2023-04-02 21:17:13,787-WARNING: In transformed code:
File "D:\pro\PaddleSlim-develop\./best_infer\onnx2paddle_0\x2paddle_code.py", line 677, in forward
x2paddle__model_2_cv1_act_Sigmoid_output_0 = self.sigmoid2(x2paddle__model_2_cv1_conv_Conv_output_0)
x2paddle__model_2_cv2_act_Sigmoid_output_0 = self.sigmoid3(x2paddle__model_2_cv2_conv_Conv_output_0)
x2paddle__model_21_m_blocks_blocks_1_Concat_output_0 = paddle.reshape(x=x2paddle__model_21_m_blocks_blocks_1_Concat_output_0, shape=[-1, 36, 36, -1, 4])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
x2paddle__model_21_m_blocks_blocks_1_Constant_2_output_0_zeros = paddle.zeros_like(x=x2paddle__model_21_m_blocks_blocks_1_Constant_2_output_0)
x2paddle__model_21_m_blocks_blocks_1_ScatterND_output_0_input_inner_indices = paddle.scatter_nd_add(x=x2paddle__model_21_m_blocks_blocks_1_Constant_2_output_0_zeros, index=x2paddle__model_21_m_blocks_blocks_1_Concat_output_0, updates=x2paddle__model_21_m_blocks_blocks_1_Reshape_1_output_0)
File "C:\Users\WANGWEI\anaconda3\envs\paddle\lib\site-packages\paddle\tensor\manipulation.py", line 3645, in reshape
attrs["shape"] = get_attr_shape(shape)
File "C:\Users\WANGWEI\anaconda3\envs\paddle\lib\site-packages\paddle\tensor\manipulation.py", line 3607, in get_attr_shape
assert unk_dim_idx == -1, (
AssertionError: Only one dimension value of 'shape' in reshape can be -1. But received shape[3] is also -1.
# N = x.shape()[2] # N is an int. (NOT recommend under @to_static)
N = paddle.shape(x)[2] # N is a Tensor. (Recommend)
z = paddle.reshape([N, -1, 4]) # z.shape is [-1, -1, 4]
If your target shape in Reshape represents dynamic shape, please turn it into a Tensor under @to_static. See above example for details.
2023-04-02 21:17:13,790-ERROR: x2paddle threw an exception, you can ask for help at: https://github.com/PaddlePaddle/X2Paddle/issues
Evaluation stage, Run batch:|████████████████████████████████████████| 2273/2273
loading annotations into memory...
Done (t=0.16s)
creating index...
index created!
Traceback (most recent call last):
File "C:\Users\WANGWEI\anaconda3\envs\paddle\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\WANGWEI\anaconda3\envs\paddle\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "c:\Users\WANGWEI.vscode\extensions\ms-python.python-2023.6.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy_main.py", line 39, in
runpy.run_path(target, run_name="main")
File "c:\Users\WANGWEI.vscode\extensions\ms-python.python-2023.6.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 321, in run_path
return _run_module_code(code, init_globals, run_name,
File "c:\Users\WANGWEI.vscode\extensions\ms-python.python-2023.6.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 135, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "c:\Users\WANGWEI.vscode\extensions\ms-python.python-2023.6.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "example/auto_compression/pytorch_yolo_series/run.py", line 149, in
同问
同问
目前我也没有解决,社区还没人回复,尝试其他的方案吧。
看起来像是修改之后的后处理和示例代码里的不太一样,可以提供下修改之后的模型吗?