提交 bdd04ab5 编写于 作者: S shenyuhan

delete filename in app, modify main.html to get modules from back

上级 10237f98
......@@ -188,14 +188,29 @@ def create_app():
request.data = {"id": str(time.time())}
pass
@app_instance.route("/get/modules", methods=["GET", "POST"])
def get_modules_info():
global nlp_module, cv_module
module_info = {}
if len(nlp_module) > 0:
module_info.update({"nlp_module": [{"Choose...": "Choose..."}]})
for item in nlp_module:
module_info["nlp_module"].append({item: item})
if len(cv_module) > 0:
module_info.update({"cv_module": [{"Choose...": "Choose..."}]})
for item in cv_module:
module_info["cv_module"].append({item: item})
module_info.update({"Choose...": [{"请先选择分类": "Choose..."}]})
return {"module_info": module_info}
@app_instance.route("/predict/image/<module_name>", methods=["POST"])
def predict_iamge(module_name):
global results_dict
req_id = request.data.get("id")
img_base64 = request.form.get("input_img", "")
received_file_name = request.form.get("input_file", "")
ext = received_file_name.split(".")[-1]
if ext == "":
ext = img_base64.split(";")[0].split("/")[-1]
if ext not in ["jpeg", "jpg", "png"]:
return {"result": "Unrecognized file type"}
score = time.time()
filename = utils.md5(str(time.time()) + str(img_base64)) + "." + ext
......
......@@ -35,8 +35,6 @@
<select class="custom-select" id="inputGroupSelect01"
onchange="select_category(this.options[this.options.selectedIndex].value)">
<option selected>Choose...</option>
<option value="nlp_module">nlp</option>
<option value="cv_module">cv</option>
</select>
</td>
<td style="width: 6%"></td>
......@@ -61,12 +59,31 @@
</div>
</form>
<script>
module_info = {
"nlp_module":[{"Choose...":"Choose..."},{"lac":"lac"},
{"senta_lstm":"senta_lstm"}],
"cv_module":[{"Choose...":"Choose..."},{"yolov3":"yolov3_coco2017"},{"faster_rcnn":"faster_rcnn_coco2017"}],
"Choose...":[{"请先选择分类":"Choose..."}]
};
var module_info = {};
$.ajax({
type: "POST",
url: "/get/modules",
data: "",
dataType: "json",
async: false,
success: function (res) {
module_info = res.module_info;
console.log(res);
console.log("mo=", module_info);
if (module_info.hasOwnProperty("nlp_module"))
{
s = document.getElementById("inputGroupSelect01");
s.options.add(new Option("nlp", "nlp_module"));
}
if (module_info.hasOwnProperty("cv_module"))
{
s = document.getElementById("inputGroupSelect01");
s.options.add(new Option("cv", "cv_module"));
}
}
});
function get_module_option(module_categoty) {
options = module_info[module_categoty];
html = "";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册