Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

caffemodel 当blob只有shape没有data时会有异常 #993

Open
1 of 3 tasks
tian161 opened this issue Sep 19, 2023 · 0 comments
Open
1 of 3 tasks

caffemodel 当blob只有shape没有data时会有异常 #993

tian161 opened this issue Sep 19, 2023 · 0 comments

Comments

@tian161
Copy link

tian161 commented Sep 19, 2023

感谢您参与 X2Paddle 社区! 问题模版为了 X2Paddle 能更好的迭代,例如新功能发布、 RoadMaps 和错误跟踪. 😸

问题描述

使用X2Paddle 进行 caffe转nb,当模型文件caffemodel的blob权重参数中只有shape没有data时,会导致报错。
这是我的模型文件.caffemodel的前面几层
name: ""
layer {
name: "input_1"
type: "Input"
top: "input_1"
phase: TEST
input_param {
shape {
dim: 1
dim: 3
dim: 160
dim: 40
}
}
}
layer {
name: "conv0"
type: "Convolution"
bottom: "input_1"
top: "conv0"
blobs {
shape {
dim: 32
dim: 3
dim: 3
dim: 3
}
}
blobs {
shape {
dim: 32
}
}
phase: TEST
convolution_param {
num_output: 32
bias_term: true
pad_h: 1
pad_w: 1
kernel_h: 3
kernel_w: 3
stride_h: 1
stride_w: 1
}
}
layer {
name: "bn0"
type: "BatchNorm"
bottom: "conv0"
top: "bn0"
blobs {
data: -0.007865031249821186
data: -0.005324164871126413
data: -0.010764184407889843
data: 0.008240368217229843
data: 0.01976969465613365
data: 0.012027844786643982
data: 0.002962957601994276
data: -0.3145563304424286
data: 0.10758233815431595
data: 0.025216389447450638
data: -0.07927775382995605
data: -0.004488849081099033
data: -0.009283231571316719
data: -0.020594490692019463
data: -0.05032395198941231
data: 0.14864583313465118
data: -0.03062831051647663
data: -0.027901044115424156
data: -0.007554500363767147
data: -0.05905086174607277
data: 0.013064151629805565
data: -0.001625223783776164
data: -0.012637660838663578
data: -0.020215753465890884
data: -0.15577200055122375
data: -0.005744390655308962
data: -0.004265745636075735
data: 0.020425138995051384
data: -0.0014742618659511209
data: 0.02395986020565033
data: 0.020134909078478813
data: -0.013855302706360817
shape {
dim: 32
}
}
blobs {
data: 0.012731957249343395
data: 0.008646254427731037
data: 0.011110151186585426
data: 0.009516902267932892
data: 0.008103199303150177
data: 0.008265161886811256
data: 0.00312191154807806
data: 0.02370261959731579
data: 0.0027517329435795546
data: 0.013189432211220264
data: 0.007192822638899088
data: 0.008816424757242203
data: 0.007724612019956112
data: 0.014152021147310734
data: 0.01284481305629015
data: 0.013880057260394096
data: 0.014332244172692299
data: 0.0011996557004749775
data: 0.015406877733767033
data: 0.010128257796168327
data: 0.002697761869058013
data: 0.0050042783841490746
data: 0.011377030052244663
data: 0.00816092174500227
data: 0.010117243975400925
data: 0.011570217087864876
data: 0.005011581815779209
data: 0.0009002541191875935
data: 0.0012184175429865718
data: 0.016399741172790527
data: 0.006782908923923969
data: 0.004564266186207533
shape {
dim: 32
}
}
blobs {
data: 1.0
shape {
dim: 1
}
}
phase: TEST
batch_norm_param {
moving_average_fraction: 0.9900000095367432
eps: 0.0010000000474974513
}
}

  • 错误信息

  • 错误截图

    File "F:\PyProject\PaddleOPT\Main.py", line 5, in
    caffe2paddle(
    File "F:\PyProject\PaddleOPT\X2Paddle\x2paddle\convert.py", line 240, in caffe2paddle
    model = CaffeDecoder(proto_file, weight_file, caffe_proto)
    File "f:\PyProject\PaddleOPT\lib\site-packages\x2paddle-1.4.1-py3.10.egg\x2paddle\decoder\caffe_decoder.py", line 292, in init
    self.load_using_pb()
    File "f:\PyProject\PaddleOPT\lib\site-packages\x2paddle-1.4.1-py3.10.egg\x2paddle\decoder\caffe_decoder.py", line 306, in load_using_pb
    self.params = [pair(layer) for layer in layers if layer.blobs]
    File "f:\PyProject\PaddleOPT\lib\site-packages\x2paddle-1.4.1-py3.10.egg\x2paddle\decoder\caffe_decoder.py", line 306, in
    self.params = [pair(layer) for layer in layers if layer.blobs]
    File "f:\PyProject\PaddleOPT\lib\site-packages\x2paddle-1.4.1-py3.10.egg\x2paddle\decoder\caffe_decoder.py", line 305, in
    pair = lambda layer: (layer.name, self.normalize_pb_data(layer))
    File "f:\PyProject\PaddleOPT\lib\site-packages\x2paddle-1.4.1-py3.10.egg\x2paddle\decoder\caffe_decoder.py", line 330, in normalize_pb_data
    list(blob.data), dtype=np.float32).reshape(c_o, c_i, h, w)
    ValueError: cannot reshape array of size 0 into shape (32,3,3,3)

具体信息

  • 转换模型后用处
    • 使用 Paddle 框架/ PaddleInference 推理预测
    • 使用 Paddle-Lite 做移动端推理
    • 转换预训练参数,再使用 Paddle 进行模型开发
  • 模型来源
    YOLOX:https://github.com/Megvii-BaseDetection/YOLOX
  • 应用场景
    用于移动端业务下的检测业务
  • 版本信息
    PaddlePaddle => ❔ 2.4.2.post117
    X2Paddle => ❔ 1.4.1
    来源框架版本(PyTorch/TF/ONNX/Caffe) => ❔ Caffe
  • 您的联系方式(邮箱/微信/电话)
    18678297327
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant