Commit 5ff3248a by 杨林龙

优化界面交互

1 parent f9211910
import os import os
import shutil
from flask import request, Blueprint from flask import request, Blueprint
import requests import requests
from flaskr.biz.identify_service import IdentifyService from flaskr.biz.identify_service import IdentifyService
...@@ -34,13 +35,18 @@ def identify(): ...@@ -34,13 +35,18 @@ def identify():
return a return a
@classfication_bp.route("/identifyLocal", methods=["POST"]) @classfication_bp.route("/upload", methods=["POST"])
def identifyLocal(): def upload():
local_img_path = request.get_json()["img_path"] file = request.files["file"] # 获取上传的文件
file.save("uploads/" + file.filename) # 保存文件到指定路径
local_img_path = "./uploads/" + file.filename
print("local_img_path===", local_img_path) print("local_img_path===", local_img_path)
(a, b) = ImageClassificationService("data/modelFile/my_model03.h5").doClassfication( (a, b) = ImageClassificationService("data/modelFile/my_model03.h5").doClassfication(
local_img_path local_img_path
) )
# 预测完以后删除文件
print("预测完以后删除文件" + local_img_path)
os.remove(local_img_path)
print(a, b) print(a, b)
return a return a
......
...@@ -5,8 +5,15 @@ ...@@ -5,8 +5,15 @@
<title>车牌识别系统</title> <title>车牌识别系统</title>
</head> </head>
<body> <body>
<h1>车牌识别</h1>
<form method="POST" enctype="multipart/form-data" action="http://127.0.0.1:5000/upload"> <form method="POST" enctype="multipart/form-data" action="http://127.0.0.1:5000/upload">
文件:<input type="file" name="file" /> 文件:<input type="file" name="file" />
<input type="submit" value="上传云端识别" /> <input type="submit" value="上传云端识别" />
</form> </form>
<h1>图片识别</h1>
<form method="POST" enctype="multipart/form-data" action="http://127.0.0.1:5000/classfication/upload">
文件:<input type="file" name="file" />
<input type="submit" value="上传云端识别" />
</form>
</html> </html>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!