diff --git a/x2paddle/convert.py b/x2paddle/convert.py index 294e1f0d65c1335bc3f47f48c9a6e57a584804a3..11420b67c27edd70e33837f55d81f54289c298b1 100644 --- a/x2paddle/convert.py +++ b/x2paddle/convert.py @@ -49,7 +49,7 @@ def arg_parser(): "--caffe_proto", "-c", type=_text_type, - default='./x2paddle/decoder/caffe_pb2.py', + default=None, help="the .py file compiled by caffe proto file of caffe model") parser.add_argument("--version", "-v", @@ -91,10 +91,6 @@ def tf2paddle(model_path, save_dir): def caffe2paddle(proto, weight, save_dir, caffe_proto): - import os - 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 from x2paddle.decoder.caffe_decoder import CaffeDecoder from x2paddle.op_mapper.caffe_op_mapper import CaffeOpMapper diff --git a/x2paddle/decoder/caffe_decoder.py b/x2paddle/decoder/caffe_decoder.py index c3d3edabaf3ac8e09b879fbc582e93ddf4e9f85b..d6a925170d259332e7d1cc7f89bf935696ceca16 100644 --- a/x2paddle/decoder/caffe_decoder.py +++ b/x2paddle/decoder/caffe_decoder.py @@ -146,6 +146,11 @@ class CaffeDecoder(object): def __init__(self, proto_path, model_path, caffe_proto): self.proto_path = proto_path self.model_path = model_path + if caffe_proto is None: + caffe_proto = './x2paddle/decoder/caffe_pb2.py' + if caffe_proto is not None and not os.path.isfile(caffe_proto): + raise Exception( + "The .py file compiled by caffe.proto is not exist.") self.resolver = CaffeResolver(caffe_proto=caffe_proto) self.net = self.resolver.NetParameter()