ubuntu+flask+nginx搭建车牌检测服务
一、购买服务器
二、上传代码
三、搭建虚拟环境
sudo pip install virtualenv
virtualenv venv
source venv/bin/activate
pip install -r requirement.txt
四、搭建uWSGI
[uwsgi]
module = wsgi:app
master = true
processes = 5
http=127.0.0.1:8090
#socket = 127.0.0.1:8090
chmod-socket = 660
vacuum = true
pidfile =uwsgi.pid
die-on-term = true
请求方法:
app = Flask(__name__)
@app.route('/ai/plate/predict', methods=['POST'])
def predict():
...
if __name__ == '__main__':
initmodel()
app.run()
启动命令:
uwsgi -d --ini plate.ini
我们还需要改下nginx.conf,如下:
upstream ai{
server 127.0.0.1:8090;
}
location /ai {
root /root/websites/ai/plate;
proxy_pass http://127.0.0.1:8090;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
limit_req zone=one burst=10 nodelay;
}
车牌检测测试页面:https://www.erbing.vip/html/index.html,
测试小程序: