pt/pth模型节点名称不同

问题描述:yolov5转caffe,再ruyi工具量化,再海思相机上推理,之前的流程没有问题,过了一段时间报错了,量化时prototxt文件节点名称报错。
正确的:

layer {
  name: "images"
  type: "Input"
  top: "images"
  input_param {
    shape {
      dim: 1
      dim: 3
      dim: 640
      dim: 640
    }
  }
}
layer {
  name: "Conv_0"
  type: "Convolution"
  bottom: "images"
  top: "131"
  convolution_param {
    num_output: 32
    bias_term: true
    group: 1
    pad_h: 1
    pad_w: 1
    kernel_h: 3
    kernel_w: 3
    stride_h: 2
    stride_w: 2
    dilation: 1
  }
}
layer {
  name: "Sigmoid_1"
  type: "Sigmoid"
  bottom: "131"
  top: "132"
}

报错的

layer {
  name: "images"
  type: "Input"
  top: "images"
  input_param {
    shape {
      dim: 1
      dim: 3
      dim: 640
      dim: 640
    }
  }
}
layer {
  name: "/model.0/conv/Conv"
  type: "Convolution"
  bottom: "images"
  top: "/model.0/conv/Conv_output_0"
  convolution_param {
    num_output: 32
    bias_term: true
    group: 1
    pad_h: 2
    pad_w: 2
    kernel_h: 6
    kernel_w: 6
    stride_h: 2
    stride_w: 2
    dilation: 1
  }
}
layer {
  name: "/model.0/act/Sigmoid"
  type: "Sigmoid"
  bottom: "/model.0/conv/Conv_output_0"
  top: "/model.0/act/Sigmoid_output_0"
}

排查onnx文件也是这样的/model.1/conv/Conv节点名称。
换了一个环境运行yolov5s的export.py文件即可得到正确的格式,所以初步分析是pytorch版本问题。
之前的环境:

python                    3.8.13               h12debd9_0  
python-dateutil           2.8.2                     <pip>
pytorch-metric-learning   1.6.3                     <pip>
pytz                      2022.1                    <pip>
PyYAML                    6.0                       <pip>
readline                  8.1.2                h7f8727e_1  
requests                  2.28.1                    <pip>
requests-oauthlib         1.3.1                     <pip>
rich                      12.5.1                    <pip>
rsa                       4.9                       <pip>
scikit-learn              1.1.1                     <pip>
scipy                     1.8.1                     <pip>
seaborn                   0.11.2                    <pip>
setuptools                61.2.0           py38h06a4308_0  
six                       1.16.0                    <pip>
soupsieve                 2.3.2.post1               <pip>
sqlite                    3.38.5               hc218d9a_0  
stack-data                0.3.0                     <pip>
tabulate                  0.8.10                    <pip>
tb-nightly                2.10.0a20220724           <pip>
tensorboard               2.9.1                     <pip>
tensorboard-data-server   0.6.1                     <pip>
tensorboard-plugin-wit    1.8.1                     <pip>
termcolor                 1.1.0                     <pip>
thop-0.1.1                2207130030                <pip>
threadpoolctl             3.1.0                     <pip>
timm                      0.6.12                    <pip>
tk                        8.6.12               h1ccaba5_0  
torch                     1.12.0                    <pip>
torchreid                 1.4.0                     <pip>
torchvision               0.13.0                    <pip>

后来的环境:

python                    3.10.4               h12debd9_0  
python-dateutil           2.8.2                     <pip>
pytorch                   1.9.0           py3.8_cuda10.2_cudnn7.6.5_0    pytorch
pytorch-mutex             1.0                        cuda    pytorch
pytz                      2022.6                    <pip>
PyYAML                    6.0                       <pip>
readline                  8.1.2                h7f8727e_1  
requests                  2.28.1                    <pip>
requests                  2.28.1           py38h06a4308_0  
requests-oauthlib         1.3.1                     <pip>
rich                      12.6.0                    <pip>
rsa                       4.8                       <pip>
scipy                     1.9.3                     <pip>
seaborn                   0.12.1                    <pip>
setuptools                65.5.0          py310h06a4308_0  
setuptools                65.5.0                    <pip>
six                       1.16.0             pyhd3eb1b0_1  
sklearn                   0.0.post1                 <pip>
sqlite                    3.38.5               hc218d9a_0  
sympy                     1.11.1                    <pip>
tensorboard               2.11.0                    <pip>
tensorboard-data-server   0.6.1                     <pip>
tensorboard-plugin-wit    1.8.1                     <pip>
thop-0.1.1                2209072238                <pip>
timm                      0.6.12                    <pip>
tk                        8.6.12               h1ccaba5_0  
torch                     1.13.0                    <pip>
torchaudio                0.9.0                      py38    pytorch
torchvision               0.10.0               py38_cu102    pytorch
torchvision               0.14.0                    <pip>

你可能感兴趣的:(caffe,人工智能,深度学习)