请问paddle2onnx支持动态输入吗?
已关闭
请问paddle2onnx支持动态输入吗?
Created by: zeze1111
我用x2paddle将PaddleOCR的DB文字检测算法转化到onnx,使用的指令是
x2paddle -f paddle2onnx -m paddle_infer_model_dir -s save_onnx_dir
推理时会报错
[ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Got invalid dimensions for input: image for the following indices index: 2 Got: 256 Expected: 640 index: 3 Got: 448 Expected: 640
这个错误的原因应该就是因为我转化后的模型不支持动态输入。
所以x2paddle转化到onnx模型支持动态输入吗?
Created by: jiangjiajun
参考此issue #283 (closed)
Created by: zeze1111
参考此issue #283 (closed)
issue #283 (closed) 里给出的方法将image_shape:[3, 640, 640]改为[3, -1, ,1]之后会在创建网络结构的时候出现错误,不论是resnet还是movilenetv3都会有这个错误,应该是必须指定图像大小的意思。
Traceback (most recent call last): File "tools/train.py", line 121, in <module> main() File "tools/train.py", line 50, in main config, train_program, startup_program, mode='train') File "tools/../tools/program.py", line 175, in build dataloader, outputs = model(mode=mode) File "tools/../ppocr/modeling/architectures/det_model.py", line 118, in __call__ conv_feas = self.backbone(image) File "tools/../ppocr/modeling/backbones/det_resnet_vd.py", line 68, in __call__ name='conv1_1') File "tools/../ppocr/modeling/backbones/det_resnet_vd.py", line 138, in conv_bn_layer bias_attr=False) File "/home/mingshuo/.local/lib/python3.6/site-packages/paddle/fluid/layers/nn.py", line 2825, in conv2d "Received: %s." % (str(input.shape), str(num_channels))) ValueError: The channel dimmention of the input((3, -1, -1)) should be defined. Received: -1.
Created by: jiangjiajun
参考此issue #283 (closed)
issue #283 (closed) 里给出的方法将image_shape:[3, 640, 640]改为[3, -1, ,1]之后会在创建网络结构的时候出现错误,不论是resnet还是movilenetv3都会有这个错误,应该是必须指定图像大小的意思。
Traceback (most recent call last): File "tools/train.py", line 121, in <module> main() File "tools/train.py", line 50, in main config, train_program, startup_program, mode='train') File "tools/../tools/program.py", line 175, in build dataloader, outputs = model(mode=mode) File "tools/../ppocr/modeling/architectures/det_model.py", line 118, in __call__ conv_feas = self.backbone(image) File "tools/../ppocr/modeling/backbones/det_resnet_vd.py", line 68, in __call__ name='conv1_1') File "tools/../ppocr/modeling/backbones/det_resnet_vd.py", line 138, in conv_bn_layer bias_attr=False) File "/home/mingshuo/.local/lib/python3.6/site-packages/paddle/fluid/layers/nn.py", line 2825, in conv2d "Received: %s." % (str(input.shape), str(num_channels))) ValueError: The channel dimmention of the input((3, -1, -1)) should be defined. Received: -1.
这可能跟PaddleOCR的代码实现相关,建议此问题咨询一下PaddleOCR团队。
目前Paddle在转ONNX模型时,是根据源模型中的信息进行转换,在PaddleOCR的组网中,将输入设置成了640640,因此转成ONNX模型后,输入大小也是640640。如需转换后的ONNX模型支持不定长大小输入,则源模型中的输入需要定义成-1*-1