Tr-text Recognition implements OCR technology
Github project address: github.com/myhub/tr
Brief introduction to the project (mainly obtained from the project Readme) :
An offline text recognition SDK for scanned documents, the core code is all developed in C++, and provides Python interface
- C++ interface support
- Support for Windows
- Add PYTHon2 support
- Remove opencv- Python and Pillow dependencies to reduce deployment difficulty
- Support for multithreading
- Support the GPU
Requirements
- Windows 7 + / Ubuntu 16.04 / Ubuntu 18.04
- Python2 / PYTHon3, numPY needs to be installed
- This installation is required for Windows
VC_redist.x64.exe
GPU version Installation Instructions (Practice: The CPU speed is very slow, you are advised to install the GPU)
- If speed is required, you are advised to install a GPU
To use the GPU version, copy the files from the TR_GPU folder to the TR folder
- Note: Must be installed first
CUDA 10.1
As well asCuDNN 7.6.5
installation
The Docker installation method is discarded by me (you can try it yourself if you are interested), and the setup.py installation method is used here
git clone https://github.com/myhub/tr.git
cd ./tr
sudo python setup.py install
Copy the code
test
Python2 demo. Py # Python2 compatibility test PYTHon3 test.py # Visualization test PYTHon3 test-multi-thread.py # Multithreaded testCopy the code
Practical steps
First of all, GPU version needs to install CUDA 10.1 and cuDNN 7.6.5 environment. Here, we adopt off-the-shelf environment (easy-to-learn intelligent platform), which can avoid various problems of installation environment and quickly realize the construction of the project. Disadvantage: cost
The official website of yi Learning intelligence: www.easyaiforum.cn/
1 enter the easy learning intelligent official website, choose the environment you need, pay to boot
1.1 Accessing the Official Website
1.2 Accessing the Console
1.3 Selecting an Environment
Billing mode: I generally choose a fixed number of hours, not enough to add the line
For GPU model, we choose 1050ti,2¥/h, and here we choose Conda101, because there are CUDa10.1 and CudNN7.6.5 in this environment
1.4 Click settlement startup
Note a few information, confirm can boot
1.5 Running screen after the STARTUP
I generally used to use the terminal way, operation, to the command is not very familiar with the small partner can use the remote desktop way
1.6 Opening the Terminal and Switching to the Specified Environment
The environment we need is Py37-CUDa101 and the toggle command is
conda activate py37-cuda101
Copy the code
Download the project to our Ubuntu host
Github is slow here, so we will copy it to Gitee and use gitee zip download
2.1 Clone the project on Github to Gitee and generate a zip link
2.2 Use the WGET method, download to the host (the fastest way in my actual combat)
2.3 Saving the Settings Enter the project
2.3.1 Decompress first
unzip xxxx.zip
Copy the code
2.3.2 Enter the Project. The installation is complete. (CPU is installed by default.
sudo python setup.py install
Copy the code
The password is obtained at this place:
There is a problem with the installation. Numpy will be downloaded, but the installation requires python >= 3.7
However, our virtual environment is python37+ CUDa101. On a close look, the installation path is not correct. We already have Numpy in our virtual environment
vim setup.py
Copy the code
Find this place and kill it
Delete these three lines, save them, and execute the above installation statement again (no problems)
Installation succeeded:
3. The installationGPUversion
The above process (default) is to install the CPU version, do not chase for speed can directly test, this part is to install the GPU
3.1 Copying files is complete
cp tr_gpu/lib* tr/
Copy the code
3.2 After the Installation is complete
sudo python setup install
Copy the code
The result is the same as the CPU installation above
4. Upload the picture and complete the test
4.1 Uploading Pictures
Note upload to the IMGS folder
4.2 Changing test Files
Change the image path in the test.py file to the data you want to test
Before the change:
After the changes:
4.3 Completing tests
python test.py
Copy the code
The total time to use gpu is 1.65785s
4.4 Viewing Effects
The original image
Identify the results
5. Practical experience of the project
- The recognition rate for horizontal text is very high, especially for printed text in the experiment, the effect is very good (
Very good
) - For the text with a certain tilt Angle, the recognition effect is good (
good
) - For vertical text, the recognition effect is poor, maybe the model does not support vertical