提交 0eb65531 编写于 作者: S SunAhong1993

fix the shufflechannel and convert.py

上级 8fecf767
......@@ -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"
)
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册