Toybrick

转换caffe模型出错

had_in

注册会员

积分
142
楼主
发表于 2020-6-29 16:14:26    查看: 7546|回复: 2 | [复制链接]    打印 | 只看该作者
求助。。
转换车牌识别库hyperlpr的caffe模型出错,原模型prototxt文件如下所示
  1. input: "data"
  2. input_dim: 1
  3. input_dim: 3
  4. input_dim: 16
  5. input_dim: 66
  6. layer {
  7.   name: "conv1"
  8.   type: "Convolution"
  9.   bottom: "data"
  10.   top: "conv1"
  11.   convolution_param {
  12.     num_output: 10
  13.     bias_term: true
  14.     pad: 0
  15.     kernel_size: 3
  16.     stride: 1
  17.   }
  18. }
  19. layer {
  20.   name: "relu1"
  21.   type: "ReLU"
  22.   bottom: "conv1"
  23.   top: "conv1"
  24. }
  25. layer {
  26.   name: "max_pooling2d_3"
  27.   type: "Pooling"
  28.   bottom: "conv1"
  29.   top: "max_pooling2d_3"
  30.   pooling_param {
  31.     pool: MAX
  32.     kernel_size: 2
  33.     stride: 2
  34.     pad: 0
  35.   }
  36. }
  37. layer {
  38.   name: "conv2"
  39.   type: "Convolution"
  40.   bottom: "max_pooling2d_3"
  41.   top: "conv2"
  42.   convolution_param {
  43.     num_output: 16
  44.     bias_term: true
  45.     pad: 0
  46.     kernel_size: 3
  47.     stride: 1
  48.   }
  49. }
  50. layer {
  51.   name: "relu2"
  52.   type: "ReLU"
  53.   bottom: "conv2"
  54.   top: "conv2"
  55. }
  56. layer {
  57.   name: "conv3"
  58.   type: "Convolution"
  59.   bottom: "conv2"
  60.   top: "conv3"
  61.   convolution_param {
  62.     num_output: 32
  63.     bias_term: true
  64.     pad: 0
  65.     kernel_size: 3
  66.     stride: 1
  67.   }
  68. }
  69. layer {
  70.   name: "relu3"
  71.   type: "ReLU"
  72.   bottom: "conv3"
  73.   top: "conv3"
  74. }
  75. layer {
  76.   name: "flatten_2"
  77.   type: "Flatten"
  78.   bottom: "conv3"
  79.   top: "flatten_2"
  80. }
  81. layer {
  82.   name: "dense"
  83.   type: "InnerProduct"
  84.   bottom: "flatten_2"
  85.   top: "dense"
  86.   inner_product_param {
  87.     num_output: 2
  88.   }
  89. }
  90. layer {
  91.   name: "relu4"
  92.   type: "ReLU"
  93.   bottom: "dense"
  94.   top: "dense"
  95. }
复制代码
我改成
  1. # input: "data"
  2. # input_dim: 1
  3. # input_dim: 3
  4. # input_dim: 16
  5. # input_dim: 66
  6. layer {
  7.   name: "data"
  8.   type: "Input"
  9.   top: "data"
  10.   input_param { shape: { dim: 1 dim: 3 dim: 16 dim: 66 } }
  11. }
  12. layer {
  13.   name: "conv1"
  14.   type: "Convolution"
  15.   bottom: "data"
  16.   top: "conv1"
  17.   convolution_param {
  18.     num_output: 10
  19.     bias_term: true
  20.     pad: 0
  21.     kernel_size: 3
  22.     stride: 1
  23.   }
  24. }
  25. layer {
  26.   name: "relu1"
  27.   type: "ReLU"
  28.   bottom: "conv1"
  29.   top: "conv1"
  30. }
  31. layer {
  32.   name: "max_pooling2d_3"
  33.   type: "Pooling"
  34.   bottom: "conv1"
  35.   top: "max_pooling2d_3"
  36.   pooling_param {
  37.     pool: MAX
  38.     kernel_size: 2
  39.     stride: 2
  40.     pad: 0
  41.   }
  42. }
  43. layer {
  44.   name: "conv2"
  45.   type: "Convolution"
  46.   bottom: "max_pooling2d_3"
  47.   top: "conv2"
  48.   convolution_param {
  49.     num_output: 16
  50.     bias_term: true
  51.     pad: 0
  52.     kernel_size: 3
  53.     stride: 1
  54.   }
  55. }
  56. layer {
  57.   name: "relu2"
  58.   type: "ReLU"
  59.   bottom: "conv2"
  60.   top: "conv2"
  61. }
  62. layer {
  63.   name: "conv3"
  64.   type: "Convolution"
  65.   bottom: "conv2"
  66.   top: "conv3"
  67.   convolution_param {
  68.     num_output: 32
  69.     bias_term: true
  70.     pad: 0
  71.     kernel_size: 3
  72.     stride: 1
  73.   }
  74. }
  75. layer {
  76.   name: "relu3"
  77.   type: "ReLU"
  78.   bottom: "conv3"
  79.   top: "conv3"
  80. }
  81. layer {
  82.   name: "flatten_2"
  83.   type: "Flatten"
  84.   bottom: "conv3"
  85.   top: "flatten_2"
  86. }
  87. layer {
  88.   name: "dense"
  89.   type: "InnerProduct"
  90.   bottom: "flatten_2"
  91.   top: "dense"
  92.   inner_product_param {
  93.     num_output: 2
  94.   }
  95. }
  96. layer {
  97.   name: "relu4"
  98.   type: "ReLU"
  99.   bottom: "dense"
  100.   top: "dense"
  101. }
复制代码
模型在加载阶段rknn.load_caffe就出错了,报错信息如下所示
  1. --> config model
  2. done
  3. --> Loading model
  4. E Catch exception when loading caffe model: ./HorizonalFinemapping.prototxt!
  5. E Traceback (most recent call last):
  6. E   File "rknn\api\rknn_base.py", line 441, in rknn.api.rknn_base.RKNNBase.load_caffe
  7. E   File "rknn\base\RKNNlib\converter\caffeloader.py", line 1042, in rknn.base.RKNNlib.converter.caffeloader.CaffeLoader.load_blobs
  8. E   File "rknn\base\RKNNlib\converter\caffeloader.py", line 935, in rknn.base.RKNNlib.converter.caffeloader.CaffeLoader.parse_blobs
  9. E   File "rknn\base\RKNNlib\converter\caffeloader.py", line 358, in rknn.base.RKNNlib.converter.caffeloader.proc_blobs_convolution
  10. E   File "G:\ProgramData\Anaconda3\envs\rknn\lib\site-packages\numpy\core\fromnumeric.py", line 292, in reshape
  11. E     return _wrapfunc(a, 'reshape', newshape, order=order)
  12. E   File "G:\ProgramData\Anaconda3\envs\rknn\lib\site-packages\numpy\core\fromnumeric.py", line 56, in _wrapfunc
  13. E     return getattr(obj, method)(*args, **kwds)
  14. E ValueError: cannot reshape array of size 0 into shape (10,3,3,3)
  15. Load model failed! Ret = -1
复制代码
模型文件地址是https://github.com/zeusees/Hyper ... nception.caffemodel
请问这可能是什么地方出问题,看输出信息,问题在第一个卷积层就出现了,但是我实在看不出来我输入层有什么问题,求指导。
我的环境是windows10,rknn版本是1.3.2
回复

使用道具 举报

had_in

注册会员

积分
142
沙发
 楼主| 发表于 2020-6-29 16:21:11 | 只看该作者
https://github.com/zeusees/Hyper ... emapping.caffemodel

不好意思,模型地址发错了
回复

使用道具 举报

had_in

注册会员

积分
142
板凳
 楼主| 发表于 2020-6-29 16:54:13 | 只看该作者
日志信息
  1. D Save log info to: ./caffe.log
  2. --> config model
  3. done
  4. --> Loading model
  5. I Set caffe proto to caffe
  6. I Load caffe model ./HorizonalFinemapping.prototxt
  7. I Parsing net parameters ...
  8. D import clients finished
  9. I Parsing layer parameters ...
  10. D Convert layer image
  11. D Convert layer conv1
  12. D Convert layer relu1
  13. D Convert layer max_pooling2d_3
  14. D Convert layer conv2
  15. D Convert layer relu2
  16. D Convert layer conv3
  17. D Convert layer relu3
  18. D Convert layer flatten_2
  19. D Convert layer dense
  20. D Convert layer relu4
  21. I Parsing connections ...
  22. D Connect: image_0,0 to conv1_1,0
  23. D Connect: conv1_1,0 to relu1_2,0
  24. D Connect: relu1_2,0 to max_pooling2d_3_3,0
  25. D Connect: max_pooling2d_3_3,0 to conv2_4,0
  26. D Connect: conv2_4,0 to relu2_5,0
  27. D Connect: relu2_5,0 to conv3_6,0
  28. D Connect: conv3_6,0 to relu3_7,0
  29. D Connect: relu3_7,0 to flatten_2_8,0
  30. D Connect: flatten_2_8,0 to dense_9,0
  31. D Connect: dense_9,0 to relu4_10,0
  32. D Connect: relu4_10,0 to output_11,0,
  33. I Load net complete.
  34. 2020-06-29 16:50:26.078880: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
  35. D Process image_0 ...
  36. D RKNN output shape(input): (0 16 66 3)
  37. D Process conv1_1 ...
  38. D RKNN output shape(convolution): (0 14 64 10)
  39. D Process relu1_2 ...
  40. D RKNN output shape(relu): (0 14 64 10)
  41. D Process max_pooling2d_3_3 ...
  42. D RKNN output shape(pooling): (0 7 32 10)
  43. D Process conv2_4 ...
  44. D RKNN output shape(convolution): (0 5 30 16)
  45. D Process relu2_5 ...
  46. D RKNN output shape(relu): (0 5 30 16)
  47. D Process conv3_6 ...
  48. D RKNN output shape(convolution): (0 3 28 32)
  49. D Process relu3_7 ...
  50. D RKNN output shape(relu): (0 3 28 32)
  51. D Process flatten_2_8 ...
  52. D RKNN output shape(flatten): (0 2688)
  53. D Process dense_9 ...
  54. D RKNN output shape(fullconnect): (0 2)
  55. D Process relu4_10 ...
  56. D RKNN output shape(relu): (0 2)
  57. D Process output_11 ...
  58. D RKNN output shape(output): (0 2)
  59. I Build  complete.
  60. I Load blobs from caffe model ./HorizonalFinemapping.caffemodel
  61. I Check if ./HorizonalFinemapping.caffemodel contains 'type' value
  62. I Parsing net blobs ...
  63. D Load blobs of conv1
  64. E Catch exception when loading caffe model: ./HorizonalFinemapping.prototxt!
  65. E Traceback (most recent call last):
  66. E   File "rknn\api\rknn_base.py", line 441, in rknn.api.rknn_base.RKNNBase.load_caffe
  67. E   File "rknn\base\RKNNlib\converter\caffeloader.py", line 1042, in rknn.base.RKNNlib.converter.caffeloader.CaffeLoader.load_blobs
  68. E   File "rknn\base\RKNNlib\converter\caffeloader.py", line 935, in rknn.base.RKNNlib.converter.caffeloader.CaffeLoader.parse_blobs
  69. E   File "rknn\base\RKNNlib\converter\caffeloader.py", line 358, in rknn.base.RKNNlib.converter.caffeloader.proc_blobs_convolution
  70. E   File "G:\ProgramData\Anaconda3\envs\rknn\lib\site-packages\numpy\core\fromnumeric.py", line 292, in reshape
  71. E     return _wrapfunc(a, 'reshape', newshape, order=order)
  72. E   File "G:\ProgramData\Anaconda3\envs\rknn\lib\site-packages\numpy\core\fromnumeric.py", line 56, in _wrapfunc
  73. E     return getattr(obj, method)(*args, **kwds)
  74. E ValueError: cannot reshape array of size 0 into shape (10,3,3,3)
  75. Load model failed! Ret = -1
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

产品中心 购买渠道 开源社区 Wiki教程 资料下载 关于Toybrick


快速回复 返回顶部 返回列表