Anakin
Anakin copied to clipboard
使用external_converter_v2目录下的converter.py转换mobilenet-ssd的caffemodle模型失败
config.yaml的文件内容如下:
OPTIONS:
Framework: CAFFE
SavePath: ./output
ResultName: mobilenet-ssd
Config:
LaunchBoard: ON
Server:
ip: 0.0.0.0
port: 8888
OptimizedGraph:
enable: OFF
path: /home/public/CLionProjects/Anakin/tools/external_converter_v2/anakin_optimized/mobilenet.anakin.bin.saved
LOGGER:
LogToPath: ./log/
WithColor: ON
TARGET:
CAFFE:
# path to proto files
ProtoPaths:
- /home/public/CLionProjects/Anakin/tools/external_converter_v2/caffe.proto
PrototxtPath: /home/public/CLionProjects/Anakin/tools/external_converter_v2/mobilenet-ssd/MobileNetSSD_deploy.prototxt
ModelPath: /home/public/CLionProjects/Anakin/tools/external_converter_v2/mobilenet-ssd/MobileNetSSD_deploy.caffemodel
其中caffe.proto文件使用来源为:https://github.com/weiliu89/caffe/blob/ssd/src/caffe/proto/caffe.proto
MobileNet-SSD模型来源为:https://github.com/chuanqi305/MobileNet-SSD
运行python converter.py
命令,执行过程中出现如下错误:
INF | 2018-09-12 19:56:12.527134 | parser_caffe.py:539 _Parsing_new() ] `--[ Match ]Parsing [Permute: conv11_mbox_conf_perm]
INF | 2018-09-12 19:56:12.527407 | parser_caffe.py:524 _Parsing_new() ] Dectect [Flatten: conv11_mbox_conf_flat]
INF | 2018-09-12 19:56:12.527663 | parser_caffe.py:539 _Parsing_new() ] `--[ Match ]Parsing [Flatten: conv11_mbox_conf_flat]
INF | 2018-09-12 19:56:12.527922 | parser_caffe.py:524 _Parsing_new() ] Dectect [PriorBox: conv11_mbox_priorbox]
INF | 2018-09-12 19:56:12.528170 | parser_caffe.py:539 _Parsing_new() ] `--[ Match ]Parsing [PriorBox: conv11_mbox_priorbox]
Traceback (most recent call last):
File "converter.py", line 20, in <module>
graph = Graph(config)
File "/home/public/CLionProjects/Anakin/tools/external_converter_v2/parser/graph.py", line 39, in __init__
self.graph_io = self.parser()
File "/home/public/CLionProjects/Anakin/tools/external_converter_v2/parser/caffe/parser_caffe.py", line 34, in __call__
return self._Parsing_new()
File "/home/public/CLionProjects/Anakin/tools/external_converter_v2/parser/caffe/parser_caffe.py", line 570, in _Parsing_new
CAFFE_LAYER_PARSER[source_layer_type](nodeIO, rlayer, tensors, opIO) # call parser automatically
File "/home/public/CLionProjects/Anakin/tools/external_converter_v2/parser/operations/op.py", line 42, in __call__
return self.parser(args)
File "/home/public/CLionProjects/Anakin/tools/external_converter_v2/parser/caffe/caffe_layer_param_transmit.py", line 39, in warpper_args
Parser(args)
File "/home/public/CLionProjects/Anakin/tools/external_converter_v2/parser/caffe/caffe_layer_param_transmit.py", line 1081, in Parser_priorbox
OpsRegister()["PriorBox"].fixed_size = list(prior_box_param.fixed_size)
AttributeError: 'PriorBoxParameter' object has no attribute 'fixed_size'
请求帮助,非常感谢!
caffe.proto 中,在priorbox参数添加3个参数: repeated float fixed_size = 20; repeated float fixed_ratio = 21; repeated float density = 22;
@xyoungli 谢谢。
@xyoungli 你好,我加了这三个参数到caffe.proto里:
message PriorBoxParameter {
// Encode/decode type.
enum CodeType {
CORNER = 1;
CENTER_SIZE = 2;
CORNER_SIZE = 3;
}
// Minimum box size (in pixels). Required!
repeated float min_size = 1;
// Maximum box size (in pixels). Required!
repeated float max_size = 2;
// Various of aspect ratios. Duplicate ratios will be ignored.
// If none is provided, we use default ratio 1.
repeated float aspect_ratio = 3;
// If true, will flip each aspect ratio.
// For example, if there is aspect ratio "r",
// we will generate aspect ratio "1.0/r" as well.
optional bool flip = 4 [default = true];
// If true, will clip the prior so that it is within [0, 1]
optional bool clip = 5 [default = false];
// Variance for adjusting the prior bboxes.
repeated float variance = 6;
// By default, we calculate img_height, img_width, step_x, step_y based on
// bottom[0] (feat) and bottom[1] (img). Unless these values are explicitely
// provided.
// Explicitly provide the img_size.
optional uint32 img_size = 7;
// Either img_size or img_h/img_w should be specified; not both.
optional uint32 img_h = 8;
optional uint32 img_w = 9;
// Explicitly provide the step size.
optional float step = 10;
// Either step or step_h/step_w should be specified; not both.
optional float step_h = 11;
optional float step_w = 12;
// Offset to the top left corner of each cell.
optional float offset = 13 [default = 0.5];
// lj
repeated float fixed_size = 20;
repeated float fixed_ratio = 21;
repeated float density = 22;
}
但是我又遇到了另一个问题:
Traceback (most recent call last):
File "/Users/xxx/Anakin/tools/external_converter_v2/converter.py", line 20, in <module>
graph = Graph(config)
File "/Users/xxx/Anakin/tools/external_converter_v2/parser/graph.py", line 23, in __init__
from caffe import CaffeParser
File "/Users/xxx/Anakin/tools/external_converter_v2/parser/caffe/__init__.py", line 5, in <module>
from parser_caffe import *
File "/Users/xxx/Anakin/tools/external_converter_v2/parser/caffe/parser_caffe.py", line 9, in <module>
from caffe_helper import *
File "/Users/xxx/Anakin/tools/external_converter_v2/parser/caffe/caffe_helper.py", line 6, in <module>
from ..pbs import *
File "/Users/xxx/Anakin/tools/external_converter_v2/parser/pbs/__init__.py", line 13, in <module>
m = __import__(module[:-3], locals(), globals())
File "/Users/xxx/Anakin/tools/external_converter_v2/parser/pbs/caffe_pb2.py", line 23, in <module>
fle_images\x18@ \x01(\x08:\x05\x66\x61lse\x12\x15\n\nconcat_dim\x18\x41 \x01(\r:\x01\x31\x12\x36\n\x11hdf5_output_param\x18\xe9\x07 \x01(\x0b\x32\x1a.caffe.HDF5OutputParameter\".\n\nPoolMethod\x12\x07\n\x03MAX\x10\x00\x12\x07\n\x03\x41VE\x10\x01\x12\x0e\n\nSTOCHASTIC\x10\x02\"W\n\x0ePReLUParameter\x12&\n\x06\x66iller\x18\x01 \x01(\x0b\x32\x16.caffe.FillerParameter\x12\x1d\n\x0e\x63hannel_shared\x18\x02 \x01(\x08:\x05\x66\x61lse*\x1c\n\x05Phase\x12\t\n\x05TRAIN\x10\x00\x12\x08\n\x04TEST\x10\x01')
File "/Users/xxx/anaconda2/envs/vf/lib/python2.7/site-packages/google/protobuf/descriptor.py", line 878, in __new__
return _message.default_pool.AddSerializedFile(serialized_pb)
TypeError: Couldn't build proto file into descriptor pool!
Invalid proto descriptor for file "caffe.proto":
caffe.proto: A file with this name is already in the pool.
请问应该怎么解决呢? Thanks in advance!
Anakin branch: developing (already up to date) protobuf version: 3.6.0
你的分支是 developing。这个问题是 protoc 尝试导入多个相同文件名的 proto 引起的冲突。你的描述看起来是 caffe.proto 冲突了。最新版本的 parser 会在运行之前清理 proto 缓存,请切换到 master 分支试试。@Knownx
@Shixiaowei02 切换到master分支并更新代码后问题解决,谢谢!