diff options
-rw-r--r-- | nlp/scripts/api_squad_offline.py | 4 | ||||
-rw-r--r-- | nlp/scripts/upload.py | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/nlp/scripts/api_squad_offline.py b/nlp/scripts/api_squad_offline.py index 87b01c4..fe541cd 100644 --- a/nlp/scripts/api_squad_offline.py +++ b/nlp/scripts/api_squad_offline.py @@ -62,7 +62,7 @@ def serving_input_fn(): def main(FLAGS_output_dir, FLAGS_init_checkpoint_squad, FLAGS_export_dir, FLAGS_predict_file=None, FLAGS_train_file=None, FLAGS_do_predict=False, FLAGS_do_train=False, FLAGS_train_batch_size=16, FLAGS_predict_batch_size=8, FLAGS_learning_rate=5e-5, FLAGS_num_train_epochs=3.0, - FLAGS_max_answer_length=100, FLAGS_max_query_length=64, FLAGS_version_2_with_negative=False,questions=[]): + FLAGS_max_answer_length=100, FLAGS_max_query_length=64, FLAGS_version_2_with_negative=False, questions=[]): tf.logging.set_verbosity(tf.logging.INFO) bert_config = modeling.BertConfig.from_json_file(FLAGS_bert_config_file) @@ -226,7 +226,7 @@ class AI2Flask: task = p.submit(main, FLAGS_output_dir, FLAGS_init_checkpoint_squad, FLAGS_export_dir, FLAGS_predict_file, FLAGS_train_file, FLAGS_do_predict, FLAGS_do_train, FLAGS_train_batch_size, FLAGS_predict_batch_size, FLAGS_learning_rate, FLAGS_num_train_epochs, - FLAGS_max_answer_length, FLAGS_max_query_length, FLAGS_version_2_with_negative,questions) + FLAGS_max_answer_length, FLAGS_max_query_length, FLAGS_version_2_with_negative, questions) threads_mapping[task_id] = task return jsonify({"message": "Task submitted successfully", "status": "0"}) diff --git a/nlp/scripts/upload.py b/nlp/scripts/upload.py index abc5610..febf880 100644 --- a/nlp/scripts/upload.py +++ b/nlp/scripts/upload.py @@ -5,7 +5,7 @@ # date = 20210918 -from flask import Flask, request, render_template +from flask import Flask, request import zipfile import shutil import os @@ -13,6 +13,7 @@ import os app = Flask(__name__) app.config['UPLOAD_FOLDER'] = 'upload/' + @app.route("/uploader", methods=["POST"]) def uploader(): print("aa") @@ -22,6 +23,7 @@ def uploader(): f.save(os.path.join(app.config['UPLOAD_FOLDER'], f.filename)) return "ok" + @app.route("/unzipFile/<fileName>", methods=["GET"]) def unzipFile(fileName): zip_file = zipfile.ZipFile(os.path.join(app.config['UPLOAD_FOLDER'], fileName)) @@ -35,6 +37,7 @@ def unzipFile(fileName): zip_file.close() return parentDir + @app.route("/deleteFile/<fileName>", methods=["GET"]) def deleteFile(fileName): path = os.path.join(app.config['UPLOAD_FOLDER'], fileName) @@ -46,6 +49,7 @@ def deleteFile(fileName): return "ok" return "ok" return "error: no such file" - + + if __name__ == '__main__': - app.run(host="0.0.0.0", port=33013)
\ No newline at end of file + app.run(host="0.0.0.0", port=33013) |