def ReadModel(proto_file): protoname, ext = os.path.splitext(proto_file) proto = deepnet_pb2.Model() if ext == '.pbtxt': proto_pbtxt = open(proto_file, 'r') text_format.Merge(proto_pbtxt.read(), proto) else: f = gzip.open(proto_file, 'rb') proto.ParseFromString(f.read()) f.close() return proto
def CopyModel(model): copy = deepnet_pb2.Model() copy.CopyFrom(model) return copy