This is an automated email from the ASF dual-hosted git repository. jxie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push: new a33ded7 fix [#7368] Caffe converter test fails, causing CI to halt for all PRs (#7381) a33ded7 is described below commit a33ded796325c8da4eebab07a18ddc616ad28098 Author: joey2014 <joe...@foxmail.com> AuthorDate: Wed Aug 9 15:19:21 2017 -0500 fix [#7368] Caffe converter test fails, causing CI to halt for all PRs (#7381) * support convert mtcnn and MobileNet model * pass python lint * put "import re" before "import caffe_parser" as lint required * correct missed checkin and pass pylint * When converting vgg16 model, the layer fc6 input name pool5 is changed to flatten_0 by _parse_proto(). It misleads adding the layer to group. * revert disable vgg-16 resnet converter check (#7369) --- tools/caffe_converter/convert_model.py | 13 ++++++++++++- tools/caffe_converter/convert_symbol.py | 21 ++++++++++----------- tools/caffe_converter/test_converter.py | 2 +- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/tools/caffe_converter/convert_model.py b/tools/caffe_converter/convert_model.py index c04a2aa..1624a01 100644 --- a/tools/caffe_converter/convert_model.py +++ b/tools/caffe_converter/convert_model.py @@ -26,6 +26,17 @@ import mxnet as mx import numpy as np from convert_symbol import convert_symbol +def prob_label(arg_names): + candidates = [arg for arg in arg_names if + not arg.endswith('data') and + not arg.endswith('_weight') and + not arg.endswith('_bias') and + not arg.endswith('_gamma') and + not arg.endswith('_beta')] + if len(candidates) == 0: + return 'prob_label' + return candidates[-1] + def convert_model(prototxt_fname, caffemodel_fname, output_prefix=None): """Convert caffe model @@ -198,7 +209,7 @@ def convert_model(prototxt_fname, caffemodel_fname, output_prefix=None): assert len(layer_blobs) == 0 if output_prefix is not None: - model = mx.mod.Module(symbol=sym, label_names=[arg_names[-1], ]) + model = mx.mod.Module(symbol=sym, label_names=[prob_label(arg_names), ]) model.bind(data_shapes=[('data', tuple(input_dim))]) model.init_params(arg_params=arg_params, aux_params=aux_params) model.save_checkpoint(output_prefix, 0) diff --git a/tools/caffe_converter/convert_symbol.py b/tools/caffe_converter/convert_symbol.py index dde3c26..13b55fe 100644 --- a/tools/caffe_converter/convert_symbol.py +++ b/tools/caffe_converter/convert_symbol.py @@ -145,6 +145,16 @@ def _parse_proto(prototxt_fname): param_string = '' skip_layer = False name = re.sub('[-/]', '_', layer.name) + for k in range(len(layer.bottom)): + if layer.bottom[k] in _output_name: + _output_name[layer.bottom[k]]['count'] = _output_name[layer.bottom[k]]['count']+1 + else: + _output_name[layer.bottom[k]] = {'count':0} + for k in range(len(layer.top)): + if layer.top[k] in _output_name: + _output_name[layer.top[k]]['count'] = _output_name[layer.top[k]]['count']+1 + else: + _output_name[layer.top[k]] = {'count':0, 'name':name} if layer.type == 'Convolution' or layer.type == 4: type_string = 'mx.symbol.Convolution' param_string = _convert_conv_param(layer.convolution_param) @@ -270,17 +280,6 @@ def _parse_proto(prototxt_fname): for j in range(len(layer.top)): mapping[layer.top[j]] = name output_name = name - for k in range(len(layer.bottom)): - if layer.bottom[k] in _output_name: - _output_name[layer.bottom[k]]['count'] = _output_name[layer.bottom[k]]['count']+1 - else: - _output_name[layer.bottom[k]] = {'count':0} - for k in range(len(layer.top)): - if layer.top[k] in _output_name: - _output_name[layer.top[k]]['count'] = _output_name[layer.top[k]]['count']+1 - else: - _output_name[layer.top[k]] = {'count':0, 'name':name} - output_name = [] for i in _output_name: if 'name' in _output_name[i] and _output_name[i]['count'] == 0: diff --git a/tools/caffe_converter/test_converter.py b/tools/caffe_converter/test_converter.py index db17c64..cdf8331 100644 --- a/tools/caffe_converter/test_converter.py +++ b/tools/caffe_converter/test_converter.py @@ -95,7 +95,7 @@ def main(): assert gpus, 'At least one GPU is needed to run test_converter in GPU mode' batch_size = 32 * len(gpus) - models = ['bvlc_googlenet'] + models = ['bvlc_googlenet', 'vgg-16', 'resnet-50'] val = download_data() for m in models: -- To stop receiving notification emails like this one, please contact ['"comm...@mxnet.apache.org" <comm...@mxnet.apache.org>'].