Software and Hardware Environment
- Ubuntu 18.04 64 – bit
- CUDA 10.1
- chineseocr_lite
- Anaconda with python 3.7
- pytorch
Introduction to the
Chineseocr_lite is an open source project that uses c++ and python to implement Chinese character recognition. It supports vertical character recognition and traditional character recognition. The total model is only 17M(very small) and supports CPU and GPU.
Basic installation and use
Download the source code from the official website, and then use Conda to create a new Python virtual environment. After activating the virtual environment, start installing Chineseocr_Lite
Git clone https://github.com/ouyanghuiyu/chineseocr_lite.git CD chinesesocr_lite conda create -n OCR python = 3.7 conda activate ocr pip install torch torchvision pip install -r requirements.txt pip install -U web.py cd psenet/pse/ rm pse.so make python app.py 8090Copy the code
Note that the version of web.py specified in required.txt will report an error when running
At this point, the project has been installed, we enter http://127.0.0.1:8090/ocr in your browser
As you can see, vertical text is basically recognizable as well
Using GPU acceleration
Go to PyTorch’s website, pytorch.org/get-started… , according to their own environment to choose, the final site will be the corresponding installation command, this is very good
PIP install torch = = 1.5.0 + cu101 torchvision = = 0.6.0 + cu101 -f https://download.pytorch.org/whl/torch_stable.htmlCopy the code
Once installed, we went to Ipython to verify
Restart the Web service. If the output from the Device block is seen as CUDA instead of CPU, then the GPU is ready
(ocr) xugaoxiang@1070Ti:~/Works/github/chineseocr_lite$ python app.py 8090 make: Entering directory '/home/xugaoxiang/Works/github/chineseocr_lite/psenet/pse' make: 'pse.so' is up to date. make: Leaving directory '/home/xugaoxiang/Works/github/chineseocr_lite/psenet/pse' device: cuda:0 load model device: Cuda :0 Load Model Device: CUDA :0 Load Model Device: CUDA :0 Load Model http://0.0.0.0:8090/Copy the code
After testing, the same image, GPU recognition time is only 1/3 of the CPU, the effect is good
The resources
- Github.com/ouyanghuiyu…
- Github.com/chineseocr/…
- Github.com/WenmuZhou/P…
- Github.com/ouyanghuiyu…