diff --git a/x2paddle/convert.py b/x2paddle/convert.py index 62be5cc6c981cadf042c5dfd664730f87309c80b..5a94e95950ae63779557abbcbd5466cdb5143180 100644 --- a/x2paddle/convert.py +++ b/x2paddle/convert.py @@ -82,17 +82,20 @@ def tf2paddle(model_path, save_dir): def caffe2paddle(proto, weight, save_dir, caffe_proto): - try: - import caffe - version = caffe.__version__ - if version == '1.0.0': - print("caffe == 1.0.0 is required") - return - except: - print("Caffe is not installed.") + if caffe_proto is not None: import os if not os.path.isfile(caffe_proto + 'caffe_pb2.py'): print("The file that resolve caffe is not exist.") + return + else: + try: + import caffe + version = caffe.__version__ + if version != '1.0.0': + print("caffe == 1.0.0 is required") + return + except: + print("Caffe is not installed.") print( "You have 2 options: 1. install caffe 2. compile the caffe.proto" ) diff --git a/x2paddle/op_mapper/caffe_custom_layer/shufflechannel.py b/x2paddle/op_mapper/caffe_custom_layer/shufflechannel.py index f742cfe9e2c1a5781ec197497dd2106290d8362d..c6321f2d415d16a56eecdfe9e2287616a3fb7f9e 100644 --- a/x2paddle/op_mapper/caffe_custom_layer/shufflechannel.py +++ b/x2paddle/op_mapper/caffe_custom_layer/shufflechannel.py @@ -8,7 +8,13 @@ def shufflechannel_shape(input_shape): def shufflechannel_layer(inputs, group=None, input_shape=None, name=None): input = inputs[0] - out = fluid.layers.shuffle_channel(input, group=group, name=name) + c_fm = fluid.layers.split(input, num_or_sections=input_shape[0][1], dim=1) + size = int(input_shape[0][1]/group) + new_c_fm = [] + for i in range(size): + for j in range(group): + new_c_fm.append(c_fm[j * size + i]) + out = fluid.layers.concat(new_c_fm, axis = 1) return out