基于百度paddlehub的OCR车牌识别--在线部署文档

官方演示地址
官方教程

#第1步:安装Anaconda

  1. wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.05-Linux-x86_64.sh
  2. sh Anaconda3-2021.05-Linux-x86_64.sh;
    • 一路回车(ENTER),直到看见yes;
    • 输入yes回车后,此时光标处输入目标路径即为你要自定义的安装路径了
  3. 将conda加入环境变量
    • vim ~/.bashrc
    • 先按i进入编辑模式
      在第一行输入:
      export PATH=“~/anaconda3/bin:$PATH”
      若安装时自定义了安装位置,则将~/anaconda3/bin改为自定义的安装目录下的bin文件夹
    • 修改后的~/.bash_profile文件应如下(其中xxx为用户名):
    # 修改后的~/.bash_profile文件应如下(其中xxx为用户名):
    export PATH="~/opt/anaconda3/bin:$PATH"
    # >>> conda initialize >>>
    # !! Contents within this block are managed by 'conda init' !!
    __conda_setup="$('/Users/xxx/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
    if [ $? -eq 0 ]; then
       eval "$__conda_setup"
    else
    if [ -f "/Users/xxx/opt/anaconda3/etc/profile.d/conda.sh" ]; then
          . "/Users/xxx/opt/anaconda3/etc/profile.d/conda.sh"
    else
           export PATH="/Users/xxx/opt/anaconda3/bin:$PATH"
       fi
    fi
    unset __conda_setup
    # <<< conda initialize <<<
    
    • 验证是否能识别conda命令
      在终端中输入source ~/.bash_profile以更新环境变量
      再在终端输入conda info --envs,若能显示当前有base环境,则conda已加入环境变量

第2步:创建conda环境

  1. 创建新的conda环境
  • 设置下载源
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
    conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
    conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/
    conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/
    conda config --add channels https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/
    
  • 设置搜索时显示通道地址 从channel中安装包时显示channel的url,这样就可以知道包的安装来源
    conda config --set show_channel_urls yes
    
  • 在命令行输入以下命令,创建名为paddle_env的环境
    # 此处为加速下载,paddle_env
    conda create --name paddle_env python=3.8
    
    • 之后命令行中会输出提示信息,输入y并回车继续安装
  1. 激活刚创建的conda环境,在命令行中输入以下命令
    # 激活paddle_env环境
    conda activate paddle_env
    
  2. 以上anaconda环境和python环境安装完毕

#第3步:安装模型

  1. 安装Paddle程序所需要库
pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple
pip install paddlehub -i https://mirror.baidu.com/pypi/simple
  1. 环境依赖
    • 该Module依赖于第三方库shapely和pyclipper,使用该Module之前,请先安装shapely和pyclipper。
    pip install shapely pyclipper
    
  2. 安装
    hub install chinese_ocr_db_crnn_server
    

#第4步:安装OCR识别服务

  1. 安装flask
pip3 install flask
  1. 安装flask-restful
pip3 install flask-restful
  1. 安装flasgger
    • 注意:需要更新setuptools
pip3 install -U setuptools
pip3 install flasgger
  1. 管理数据库的依赖
pip3 install flask_script
pip3 install flask_migrate

5.安装FastAPI python web 框架

pip install fastapi
pip install "uvicorn[standard]"

#第5步: 部署

  1. 安装Gunicorn
pip install gunicorn
+ 查看帮助
gunicorn -h
  1. 以命令行方式启动应用
gunicorn main:app -b 0.0.0.0:6699 -w 4 -k uvicorn.workers.UvicornWorker --daemon  --error ocr.log

前台运行:uvicorn main:app --reload

  1. 获取Gunicorn进程树
pstree -ap | grep gunicorn
  1. 终止Gunicorn任务
pkill -f gunicorn
  • 17
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值