X2Paddle
X2Paddle copied to clipboard
caffe模型转paddle
我是通过pip命令安装的X2paddle转换工具,转换caffe模型遇到以下问题: 1、concat算子转换后维度错误,例如L.Concat(pattern2, pattern2, concat_param={'concat_dim':3}),转换生成的代码为concat2 = paddle.concat(x=[concat1, concat1], axis=1),concat维度从3变成了1,导致后续计算错误; 2、返回变量首字母变成大写,导致出现变量未定义的错误,如reshape2 = paddle.reshape(...) return Reshape2
- 转换模型后用处 使用 Paddle-Lite 做移动端推理
- 应用场景 用于移动端业务下的检测业务
- 版本信息 X2Paddle:1.3.7 来源框架版本caffe:1.0.0
- 您的联系方式(邮箱/微信/电话) [email protected]
@zhongqinghong 您好,感谢反馈~
麻烦提供一下相关模型以及转换脚本
另外还有个问题需要描述一下: 1、为什么有转到Paddle部署的需求呢?
感谢~
1.因公司原因,模型不方便提供; 2.转换是直接使用的命令行x2paddle --framework=caffe ...... 3.在开展模型部署调研,对比不同的框架,考虑采用paddle_lite的方式,但有两个模型转换都失败。
---原始邮件--- 发件人: @.> 发送时间: 2022年7月12日(周二) 上午10:59 收件人: @.>; 抄送: @.@.>; 主题: Re: [PaddlePaddle/X2Paddle] caffe模型转paddle (Issue #828)
@zhongqinghong 您好,感谢反馈~
麻烦提供一下相关模型以及转换脚本
另外还有个问题需要描述一下: 1、为什么有转到Paddle部署的需求呢?
感谢~
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
我写了一个简化的caffe模型,prototxt文件如下,concat的维度错误和变量返回首字母变大写这两个问题都会出现。
name:"test_net"
input:"data" input_dim:1 input_dim:1 input_dim:3 input_dim:3
layer { name: "Conv" type: "Convolution" bottom: "data" top: "Convolution1" param { lr_mult: 1.0 decay_mult: 1.0 } param { lr_mult: 2.0 decay_mult: 1.0 } convolution_param { num_output: 64 weight_filler { type: "xavier" } bias_filler { type: "constant" value: 0.0 } pad_h: 1 pad_w: 1 kernel_h: 3 kernel_w: 3 stride_h: 1 stride_w: 1 } } layer { name: "ReLU1" type: "ReLU" bottom: "Convolution1" top: "Convolution1" } layer { name: "Concat1" type: "Concat" bottom: "Convolution1" bottom: "Convolution1" top: "Concat1" concat_param { concat_dim: 3 } }
转换过程中自动生成的paddle网络结构如下: class test_net(paddle.nn.Layer): def init(self): super(test_net, self).init() self.conv0 = paddle.nn.Conv2D(in_channels=1, out_channels=64, kernel_size=[3, 3], padding=1) self.relu0 = paddle.nn.ReLU()
def forward(self, data):
conv = self.conv0(data)
relu1 = self.relu0(conv)
concat1 = paddle.concat(x=[relu1, relu1], axis=1)
return Concat1
@zhongqinghong 仅提供prototxt还是没办法复现错误
有一种解决方案:
1、将caffe concat参数concat_dim
改为axis
你试试看能否解决