Example #1
0
def start_server():
    from bert_base.server import BertServer
    from bert_base.server.helper import get_run_args

    args = get_run_args()
    server = BertServer(args)
    server.start()
    server.join()
Example #2
0
def start_server():
    from bert_base.server import BertServer
    from bert_base.server.helper import get_run_args

    args = get_run_args()
    print(args)
    import ipdb
    #ipdb.set_trace()
    server = BertServer(args)
    server.start()
    server.join()
Example #3
0
app = Flask(__name__)

from bert_base.server.helper import get_run_args
import os
import helpers


class BertMsg():
    def __init__(self, msg):
        self.msg = msg


#------------------------------------------------------------------------------------------

##获取模型运行参数
args = get_run_args()

num_labels, label2id, id2label = helpers.init_predict_var(
    args.classify_model_pb_dir)
classify_graph_path = os.path.join(args.classify_model_pb_dir,
                                   "classification_model.pb")
with tf.gfile.GFile(classify_graph_path, 'rb') as f:
    classify_graph_def = tf.GraphDef()
    classify_graph_def.ParseFromString(f.read())
classify_bertWorker = BertWorker(args, args.device_map, classify_graph_path,
                                 "CLASS", id2label, "", "")

msg = []
classify_bert = BertMsg(msg)
classify_estimator = classify_bertWorker.get_estimator(tf, classify_graph_def,
                                                       "CLASS")