From c236c3c2d1658ba85507934afcaf231e047a55a0 Mon Sep 17 00:00:00 2001 From: SunAhong1993 Date: Wed, 11 Nov 2020 12:22:20 +0800 Subject: [PATCH] fix the caffe name bug --- x2paddle/decoder/caffe_decoder.py | 4 +++- x2paddle/op_mapper/caffe_op_mapper.py | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/x2paddle/decoder/caffe_decoder.py b/x2paddle/decoder/caffe_decoder.py index 4174cc2..f9ad281 100644 --- a/x2paddle/decoder/caffe_decoder.py +++ b/x2paddle/decoder/caffe_decoder.py @@ -104,6 +104,8 @@ class CaffeGraph(Graph): if not exclude: filtered_layers.append(layer) # Guard against dupes. + if layer.name in filtered_layer_names: + layer.name += "_0" assert layer.name not in filtered_layer_names filtered_layer_names.add(layer.name) else: @@ -224,7 +226,7 @@ class CaffeGraph(Graph): assert input_node_name in self.node_map, 'The {} isn\'t a valid node'.format( name) input_node = self.node_map[input_node_name] - if len(input_node.layer.top) > 1: + if len(input_node.layer.top) > 1 and input_node.layer_type != "Input": need_idx = list(input_node.layer.top).index(node.layer.bottom[idx]) name = input_node_name + ':' + str(need_idx) else: diff --git a/x2paddle/op_mapper/caffe_op_mapper.py b/x2paddle/op_mapper/caffe_op_mapper.py index 4283bfe..3e13776 100644 --- a/x2paddle/op_mapper/caffe_op_mapper.py +++ b/x2paddle/op_mapper/caffe_op_mapper.py @@ -81,7 +81,6 @@ class CaffeOpMapper(OpMapper): input_shape.append(last_node.output_shape[idx]) node.input_shape = input_shape - func_name = 'shape_' + node.layer_type.lower() if is_fluid_op: node.output_shape = getattr(caffe_shape, func_name)(node.layer, -- GitLab