diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4d12f23 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +#基于的基础镜像 +FROM python:3.6 +#代码添加到code文件夹,后面可以通过进入容器中看的 +ADD ./ /code +# 设置code文件夹是工作目录 +WORKDIR /code +# 安装支持 +RUN pip install -r requirement.txt -i https://pypi.tuna.tsinghua.edu.cn/simple +#当容器启动时,使用python3执行指定路径的py脚本 +CMD ["python", "/code/WebAPI.py"] + diff --git a/WebAPI.py b/WebAPI.py index 19f8cf0..a127e2c 100644 --- a/WebAPI.py +++ b/WebAPI.py @@ -1,13 +1,13 @@ #coding=utf-8 from flask import Flask, render_template, request -from werkzeug import secure_filename +from werkzeug.utils import secure_filename import cv2 import numpy as np #导入opencv -from hyperlpr import pipline +from hyperlpr_py3 import pipline #导入车牌识别库 @@ -43,7 +43,7 @@ def upload_file(): #保存请求上来的文件 t0 = time.time() res = recognize("./images_rec/"+secure_filename(f.filename)) - print "识别时间",time.time() - t0 + print("识别时间",time.time() - t0) return res #返回识别结果 @@ -51,10 +51,8 @@ def upload_file(): return render_template('upload.html') - if __name__ == '__main__': #入口函数 - - app.run("0.0.0.0",port=8000) + app.run("0.0.0.0", port=8000, threaded=False, debug=False) #运行app 指定IP 指定端口 diff --git a/demo.py b/demo.py index d39ab23..6804b1f 100644 --- a/demo.py +++ b/demo.py @@ -41,7 +41,7 @@ def drawRectBox(image,rect,addText): import HyperLPRLite as pr import cv2 import numpy as np -grr = cv2.imread("images_rec/2_.jpg") +grr = cv2.imread("images_rec/2.jpg") model = pr.LPR("model/cascade.xml","model/model12.h5","model/ocr_plate_all_gru.h5") for pstr,confidence,rect in model.SimpleRecognizePlateByE2E(grr): if confidence>0.7: @@ -56,4 +56,4 @@ cv2.waitKey(0) -SpeedTest("images_rec/2_.jpg") +#SpeedTest("images_rec/2.jpg") diff --git a/hyperlpr_py3/pipline.py b/hyperlpr_py3/pipline.py index 3a37dd3..ef5c619 100644 --- a/hyperlpr_py3/pipline.py +++ b/hyperlpr_py3/pipline.py @@ -145,9 +145,9 @@ def RecognizePlateJson(image): res_json["w"] = int(rect[2]) res_json["h"] = int(rect[3]) jsons.append(res_json) - print(json.dumps(jsons,ensure_ascii=False,encoding="gb2312")) + print(json.dumps(jsons,ensure_ascii=False)) - return json.dumps(jsons,ensure_ascii=False,encoding="gb2312") + return json.dumps(jsons,ensure_ascii=False) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..0d9fcca --- /dev/null +++ b/requirements.txt @@ -0,0 +1,53 @@ +absl-py==0.9.0 +alembic==1.4.2 +astor==0.8.1 +click==7.1.1 +cycler==0.10.0 +decorator==4.4.2 +Flask==1.0 +Flask-Migrate==2.5.3 +Flask-MySQLdb==0.2.0 +Flask-Script==2.0.6 +Flask-Session==0.3.1 +Flask-SQLAlchemy==2.4.1 +gast==0.3.3 +grpcio==1.27.2 +h5py==2.10.0 +imageio==2.8.0 +itsdangerous==1.1.0 +Jinja2==2.11.1 +joblib==0.14.1 +Keras==2.1.1 +Keras-Applications==1.0.8 +Keras-Preprocessing==1.1.0 +kiwisolver==1.1.0 +Mako==1.1.2 +Markdown==3.2.1 +MarkupSafe==1.1.1 +matplotlib==3.2.1 +mock==4.0.2 +mysqlclient==1.4.6 +networkx==2.4 +numpy==1.17.4 +opencv-contrib-python==3.4.2.16 +opencv-python==3.4.2.16 +Pillow==7.0.0 +protobuf==3.11.3 +pyparsing==2.4.6 +python-dateutil==2.8.1 +python-editor==1.0.4 +PyWavelets==1.1.1 +PyYAML==5.3.1 +redis==3.4.1 +scikit-image==0.16.2 +scikit-learn==0.22.2.post1 +scipy==1.4.1 +six==1.14.0 +sklearn==0.0 +SQLAlchemy==1.3.15 +tensorboard==1.13.1 +tensorflow==1.15.2 +tensorflow-estimator==1.13.0 +termcolor==1.1.0 +Theano==1.0.4 +Werkzeug==1.0.0