深度学习之YOLOv5实践应用(5-1)WEB端部署(Flask+VUE)

2022/3/11 23:19:07

本文主要是介绍深度学习之YOLOv5实践应用(5-1)WEB端部署(Flask+VUE),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

源码参见:Yolov5-Flask-VUE:在WEB端部署YOLOv5目标检测模型-源码

一、Flask

参见 : 安装 — Flask 0.10.1 文档

1、sudo apt-get install python3-pip

2、sudo pip3 install Flask

(yolov5) robot@robot-All-Series:~$ sudo pip3 install Flask
Collecting Flask
  Downloading Flask-2.0.3-py3-none-any.whl (95 kB)
     |████████████████████████████████| 95 kB 659 kB/s 
Collecting Jinja2>=3.0
  Downloading Jinja2-3.0.3-py3-none-any.whl (133 kB)
     |████████████████████████████████| 133 kB 317 kB/s 
Collecting itsdangerous>=2.0
  Downloading itsdangerous-2.1.1-py3-none-any.whl (15 kB)
Collecting click>=7.1.2
  Downloading click-8.0.4-py3-none-any.whl (97 kB)
     |████████████████████████████████| 97 kB 416 kB/s 
Collecting Werkzeug>=2.0
  Downloading Werkzeug-2.0.3-py3-none-any.whl (289 kB)
     |████████████████████████████████| 289 kB 222 kB/s 
Collecting MarkupSafe>=2.0
  Downloading MarkupSafe-2.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Installing collected packages: MarkupSafe, Jinja2, itsdangerous, click, Werkzeug, Flask
  Attempting uninstall: MarkupSafe
    Found existing installation: MarkupSafe 1.1.0
    Not uninstalling markupsafe at /usr/lib/python3/dist-packages, outside environment /usr
    Can't uninstall 'MarkupSafe'. No files were found to uninstall.
  Attempting uninstall: click
    Found existing installation: Click 7.0
    Not uninstalling click at /usr/lib/python3/dist-packages, outside environment /usr
    Can't uninstall 'Click'. No files were found to uninstall.
Successfully installed Flask-2.0.3 Jinja2-3.0.3 MarkupSafe-2.1.0 Werkzeug-2.0.3 click-8.0.4 itsdangerous-2.1.1

二、入门

快速入门 — Flask 0.10.1 文档

编写app.py

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello World!'

if __name__ == '__main__':
    app.run()

python3 app.py

提示错误,找不到库

Traceback (most recent call last):
  File "/home/robot/flask-test/app.py", line 1, in <module>
    from flask import Flask
ModuleNotFoundError: No module named 'flask

我用的anaconda虚拟环境。所以:

pip uninstall Flask && python3 -m pip install flask

然后重新执行

(yolov5) robot@robot-All-Series:~/flask-test$ python3 app.py
 * Serving Flask app 'app' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [11/Mar/2022 11:29:23] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [11/Mar/2022 11:29:23] "GET /favicon.ico HTTP/1.1" 404 -



这篇关于深度学习之YOLOv5实践应用(5-1)WEB端部署(Flask+VUE)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程