Exemple #1
0
 def __init__(self):
     self.config = tf.ConfigProto(
         gpu_options=tf.GPUOptions(per_process_gpu_memory_fraction=0.23),
         # device_count = {'gpu': 2}
     )
     self.session = tf.Session(config=self.config)
     self.model_test = create_model
     self.dataset = list(
         data_utils.prepare_multi_task_data(FLAGS.data_dir,
                                            FLAGS.in_vocab_size,
                                            FLAGS.out_vocab_size))
     self.pred = run_valid_test(self.session,
                                self.model_test,
                                mode='Test',
                                data_set=self.dataset)
Exemple #2
0
def query():
    message = str(request.args.get('message'))
    for way in WAY_LS:
        if way in message:
            message = message.replace("-", " ")
    user_in = PrepUtility.create_test_seq_in(message)
    PrepUtility.prepareNLUMessage(user_in, test_seq_in_path)
    date_set = prepare_multi_task_data(data_path, 10000, 10000)
    date_set = list(date_set)
    in_seq_test, out_seq_test, label_test = date_set[2]
    test_set = read_data_test(in_seq_test, out_seq_test, label_test)
    start = time.time()
    predictions = model.predict(test_set)
    #print(time.time()-start)
    response = get_response(message)
    return jsonify(response)
Exemple #3
0
    if ckpt:
        print("Reading model parameters from %s" % ckpt.model_checkpoint_path)
        model_test.saver.restore(session, ckpt.model_checkpoint_path)

        # model_train.saver.restore(session, ckpt.model_checkpoint_path)
    else:
        print("Created model with fresh parameters.")
        session.run(tf.global_variables_initializer())
    return model_test  #model_train,


vocab_path = ''
tag_vocab_path = ''
label_vocab_path = ''
date_set = data_utils.prepare_multi_task_data(FLAGS.data_dir,
                                              FLAGS.in_vocab_size,
                                              FLAGS.out_vocab_size)
date_set = list(date_set)
in_seq_train, out_seq_train, label_train = date_set[0]
in_seq_dev, out_seq_dev, label_dev = date_set[1]

in_seq_test, out_seq_test, label_test = date_set[2]
vocab_path, tag_vocab_path, label_vocab_path = date_set[3]

result_dir = FLAGS.model_dir + '/test_results'
if not os.path.isdir(result_dir):
    os.makedirs(result_dir)

current_taging_valid_out_file = result_dir + '/tagging.valid.hyp.txt'
current_taging_test_out_file = result_dir + '/tagging.test.hyp.txt'
Exemple #4
0
    date_set = list(date_set)
    in_seq_test, out_seq_test, label_test = date_set[2]
    test_set = read_data_test(in_seq_test, out_seq_test, label_test)
    start = time.time()
    predictions = model.predict(test_set)
    #print(time.time()-start)
    response = get_response(message)
    return jsonify(response)


@app.route("/api/countries")
def countries():
    response = dict(countries=COUNTRIES, classes=CLASSES)
    return jsonify(response)


# Load chatting page
@app.route('/')
def index():
    return render_template('chat.html')


if __name__ == "__main__":
    date_set = prepare_multi_task_data(data_path, 10000, 10000)
    date_set = list(date_set)
    in_seq_test, out_seq_test, label_test = date_set[2]
    test_set = read_data_test(in_seq_test, out_seq_test, label_test)
    model.predict(test_set)
    write_json(dict(), "ticket.json")
    app.run(debug=False, port=1234)