diff --git a/x2paddle/op_mapper/caffe_op_mapper.py b/x2paddle/op_mapper/caffe_op_mapper.py index e398f2b120d306733759d10eb0a90eb3da7c7e86..70ed9ecee91d9605d4b301fd79a1b5edde8db93e 100644 --- a/x2paddle/op_mapper/caffe_op_mapper.py +++ b/x2paddle/op_mapper/caffe_op_mapper.py @@ -797,21 +797,21 @@ class CaffeOpMapper(OpMapper): input = self.graph.get_bottom_node(node, idx=0, copy=True) example = self.graph.get_bottom_node(node, idx=1, copy=True) params = node.layer.crop_param - axis = parmas.axis + axis = params.axis input_shape = node.input_shape[0] if axis < 0: axis += len(input_shape) offset_real = [0] * len(input_shape) - if hasattr(params, offset): + if hasattr(params, "offset") and len(params.offset) > 0: offset = list(params.offset) assert (len(input_shape) - axis) == len( offset), "invalid offset[%s] in crop layer" % (str(offset)) offset_real = [0] * axis + offset - attr = {'offsets': offset_real, 'name': string(node.layer_name)} + attr = {'offsets': list(offset_real), 'name': string(node.layer_name)} node.fluid_code.add_layer("crop", inputs={ 'x': input, - 'y': example + 'shape': node.input_shape[1] }, output=node, param_attr=attr)