From df8da649182a7099b2d1e3a2729af354c258cd8d Mon Sep 17 00:00:00 2001 From: SunAhong1993 Date: Tue, 6 Aug 2019 18:01:23 +0800 Subject: [PATCH] fix the convert.py --- x2paddle/convert.py | 16 ++++++++-------- x2paddle/decoder/caffe_decoder.py | 17 ++++++++--------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/x2paddle/convert.py b/x2paddle/convert.py index 44a78ee..5749de6 100644 --- a/x2paddle/convert.py +++ b/x2paddle/convert.py @@ -45,11 +45,12 @@ def arg_parser(): type=_text_type, default=None, help="define which deeplearning framework") - parser.add_argument("--caffe_proto", - "-c", - type=_text_type, - default='./x2paddle/decoder/caffe_pb2.py', - help="caffe proto file of caffe model") + parser.add_argument( + "--caffe_proto", + "-c", + type=_text_type, + default=None, + help="the .py file compiled by caffe proto file of caffe model") parser.add_argument("--version", "-v", action="store_true", @@ -92,9 +93,8 @@ def tf2paddle(model_path, save_dir): def caffe2paddle(proto, weight, save_dir, caffe_proto): if caffe_proto is not None: import os - print(caffe_proto) - if caffe_proto != 'None' and not os.path.isfile(caffe_proto): - print("The file that resolve caffe is not exist.") + if caffe_proto is not None and not os.path.isfile(caffe_proto): + print("The .py file compiled by caffe.proto is not exist.") return else: try: diff --git a/x2paddle/decoder/caffe_decoder.py b/x2paddle/decoder/caffe_decoder.py index c284b72..5795dff 100644 --- a/x2paddle/decoder/caffe_decoder.py +++ b/x2paddle/decoder/caffe_decoder.py @@ -24,7 +24,7 @@ from x2paddle.op_mapper import caffe_shape class CaffeResolver(object): def __init__(self, caffe_proto): self.proto_path = caffe_proto - if self.proto_path == 'None': + if self.proto_path is None: self.use_default = True else: self.use_default = False @@ -143,11 +143,12 @@ class CaffeGraph(Graph): ]))).to_proto().layer[0]) except: print( - "The .py fiel compiled by .proto file does not work for the old style prototxt. " + "The .py file compiled by .proto file does not work for the old style prototxt. " ) print("There are 2 solutions for you as below:") print( - "1. install caffe and set \'--caffe_proto=None\'.") + "1. install caffe and don\'t set \'--caffe_proto\'." + ) print( "2. modify your .prototxt from the old style to the new style." ) @@ -166,11 +167,12 @@ class CaffeGraph(Graph): ]))).to_proto().layer[0]) except: print( - "The .py fiel compiled by .proto file does not work for the old style prototxt. " + "The .py file compiled by .proto file does not work for the old style prototxt. " ) print("There are 2 solutions for you as below:") print( - "1. install caffe and set \'--caffe_proto=None\'.") + "1. install caffe and don\'t set \'--caffe_proto\'." + ) print( "2. modify your .prototxt from the old style to the new style." ) @@ -219,10 +221,7 @@ class CaffeGraph(Graph): class CaffeDecoder(object): - def __init__(self, - proto_path, - model_path, - caffe_proto='./x2paddle/decoder/caffe_pb2.py'): + def __init__(self, proto_path, model_path, caffe_proto=None): self.proto_path = proto_path self.model_path = model_path -- GitLab