Linux--chineseocr-app

五、调试chineseocr-app

  1. 首先,将这个项目先下载下来:git clone https://github.com/chineseocr/chineseocr.git

先看readme,根据readme配置环境,参考setup.md和setup-cpu.md

conda create -n chineseocr python=3.6 pip
scipy numpy jupyter ipython ##运用conda 创建python环境

source activate chineseocr #激活环境

安装必要的模型包

git submodule init && git submodule
update

pip install easydict
opencv-contrib-python==4.0.0.21 Cython h5py lmdb mahotas pandas requests bs4
matplotlib lxml -i https://pypi.tuna.tsinghua.edu.cn/simple/

pip install -U pillow -i
https://pypi.tuna.tsinghua.edu.cn/simple/

pip install keras2.1.5 tensorflow1.8
tensorflow-gpu==1.8

pip install web.py==0.40.dev0 redis

conda install pytorch torchvision -c
pytorch

pip install torch torchvision

在这里,我用pip安装的时候,会有一些红色的错误代码,查了查,是下载源的问题,然后我制定下载源下载

pip install 需要下载的模块 -i https://pypi.doubanio.com/simple

然后下载速度就比较稳定也比较快了而且也不会出错误

  1. 下载编译darknet

git clone
https://github.com/pjreddie/darknet.git

下载完之后移动到chineseocr文件下

3.然后##编译对GPU、cudnn的支持
修改 Makefile

#GPU=1

#CUDNN=1

#OPENCV=0

#OPENMP=0

Make

  1. 修改 darknet/python/darknet.py line 48

root = ‘/root/’##chineseocr所在目录

lib =
CDLL(root+“chineseocr/darknet/libdarknet.so”, RTLD_GLOBAL)

  1. 下载模型文件

模型文件地址:

复制文件夹中的所有文件到models目录

模型转换

pytorch ocr 转keras ocr
在这里插入图片描述
在这里插入图片描述

darknet 转keras

在这里插入图片描述
在这里插入图片描述
有一个错误 把encoding=’utf-8’去掉 然后成功
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
keras 转darknet
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
去掉encoding=’utf-8’之后又有错误,不过还是这个错误所以,找到文件的281行 去掉它即可
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-s8JYGKpB-1588321106788)(https://img-bluog.csdnimg.cn/20200501160716335.png)]
在这里插入图片描述
在这里插入图片描述

模型转化完成

  1. 编译语言模型(可选)

git clone
–recursive https://github.com/parlance/ctcdecode.git

cd ctcdecode

pip install .


## 下载语言模型 (可选)

```Bash

wget
https:/'t/deepspeech.bj.bcebos.com/zh_lm/zh_giga.no_cna_cmn.prune01244.klm

mv
zh_giga.no_cna_cmn.prune01244.klm chineseocr/models/

模型选择

参考config.py文件

  1. 构建docker镜像

##下载Anaconda3 python 环境安装包(https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh)
放置在chineseocr目录下

##建立镜像

docker build -t
chineseocr .

##启动服务

docker run -d -p
8080:8080 chineseocr /root/anaconda3/bin/python app.py

在这里插入图片描述

没有doocker首先需要安装一个docker 先更新apt包索引sudo apt-get update 然后安装

在这里插入图片描述

测试 Docker 是否安装成功,输入以下指令sudo docker
run hello-world

打印出以下信息则安装成功:

Unable to find image
‘hello-world:latest’ locally

latest: Pulling from library/hello-world

1b930d010525: Pull complete
u

   Digest: sha256:c3b4ada4687bbaa170745b3e4dd8ac3f194ca95b2d0518b417fb47e5879d9b5f

Status: Downloaded newer image for hello-world:latest

Hello from Docker!

This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

  1. The Docker client contacted the Docker daemon.

  2. The Docker daemon pulled the “hello-wo’grld” image from the
    Docker Hub.

    (amd64)

  3. The Docker daemon created a new container from that image which
    runs the

    executable that produces the output you are currently reading.

  4. The Docker daemon streamed that output to the Docker client, which
    sent it

    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:

$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:

https://hub.docker.ceom/

For more examples and ideas, visit:

https://docs.docker.com/get-started/

docker是安装在根目录下的,有十几G吧,根目录的空间一定要够。安装完之后检测一下是否安装成功docker -V 在运行docker的时候还需要docker login 登录一下 否则的话会出现这个错误:docker: Error response from daemon: pull access denied for chineseocr, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.

建立镜像和启动服务的时候需要加sudo 因为我的根目录空间不足,所以建立镜像的时候,安到一半满了
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

根目录已经满了 然后我又找到了一篇博客,把docker从根目录迁移到home里面,然后第一次迁移,有部分没有迁移过去,然后又迁移了一遍,然后home满了,Ubuntu打不开了,然后进入命令行模式,把home目录下的文件删了删,进入到了图形界面,home里腾出了20多G空间,最后把docker迁移到了home里面,然后再构建镜像,然后启动服务,最后成功

了。

web服务启动

cd chineseocr## 进入chineseocr目录

python app.py 8080 ##8080端口号,可以设置任意端口

对于python2.7来说在这里插入图片描述
去掉*
在这里插入图片描述
改为
在这里插入图片描述

然后app.py运行成功

再## 访问服务

http://127.0.0.1:8080/ocr
结果图:

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值