From 9147e53a5d5506c4e021964993a1d4e9fb281822 Mon Sep 17 00:00:00 2001 From: SunAhong1993 Date: Wed, 7 Aug 2019 21:35:38 +0800 Subject: [PATCH] only develop caffe.proto --- x2paddle/convert.py | 6 +----- x2paddle/decoder/caffe_decoder.py | 5 +++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/x2paddle/convert.py b/x2paddle/convert.py index 294e1f0..11420b6 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 c3d3eda..d6a9251 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() -- GitLab