PPOCRLabel
PPOCRLabel is a semi-automatic graphic annotation tool suitable for OCR field, with built-in PP-OCR model to automatically detect and re-recognize data. It is written in Python 3 and PyQT5, supporting rectangular box annotation and four-point annotation modes. Annotations can be directly used for the training of PP-OCR detection and recognition models.
Install / Use
/learn @Evezerest/PPOCRLabelREADME
English | 简体中文
PPOCRLabelv2
PPOCRLabelv2 is a semi-automatic graphic annotation tool suitable for OCR field, with built-in PP-OCR model to automatically detect and re-recognize data. It is written in Python3 and PyQT5, supporting rectangular box, table, irregular text and key information annotation modes. Annotations can be directly used for the training of PP-OCR detection and recognition models.
| regular text annotation | table annotation | | :-------------------------------------------------: | :--------------------------------------------: | | <img src="./data/gif/steps_en.gif" width="80%"/> | <img src="./data/gif/table.gif" width="100%"/> | | irregular text annotation | key information annotation | | <img src="./data/gif/multi-point.gif" width="80%"/> | <img src="./data/gif/kie.gif" width="300%"/> |
Recent Update
- 2022.05: Add table annotations, follow
2.2 Table Annotationsfor more information (by whjdark; Evezerest) - 2022.02:(by PeterH0323 )
- Add KIE Mode by using
--kie, for [detection + identification + keyword extraction] labeling. - Improve user experience: support using
CorXto rotate box, prompt for the number of files and labels, optimize interaction.
- Add KIE Mode by using
- 2021.11.17:
- Support install and start PPOCRLabel through the whl package (by d2623587501)
- Dataset segmentation: Divide the annotation file into training, verification and testing parts (refer to section 3.5 below, by MrCuiHao)
- 2021.8.11:
- New functions: Open the dataset folder, image rotation (Note: Please delete the label box before rotating the image) (by Wei-JL)
- Added shortcut key description (Help-Shortcut Key), repaired the direction shortcut key movement function under batch processing (by d2623587501)
- 2021.2.5: New batch processing and undo functions (by Evezerest):
- Batch processing function: Press and hold the Ctrl key to select the box, you can move, copy, and delete in batches.
- Undo function: In the process of drawing a four-point label box or after editing the box, press Ctrl+Z to undo the previous operation.
- Fix image rotation and size problems, optimize the process of editing the mark frame (by ninetailskim、 edencfc).
- 2021.1.11: Optimize the labeling experience (by edencfc),
- Users can choose whether to pop up the label input dialog after drawing the detection box in "View - Pop-up Label Input Dialog".
- The recognition result scrolls synchronously when users click related detection box.
- Click to modify the recognition result.(If you can't change the result, please switch to the system default input method, or switch back to the original input method again)
- 2020.12.18: Support re-recognition of a single label box (by ninetailskim ), perfect shortcut keys.
1. Installation and Run
1.1 Install PaddlePaddle
pip3 install --upgrade pip
# If you have cuda9 or cuda10 installed on your machine, please run the following command to install
python3 -m pip install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simple
# If you only have cpu on your machine, please run the following command to install
python3 -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple
For more software version requirements, please refer to the instructions in Installation Document for operation.
1.2 Install and Run PPOCRLabel
PPOCRLabel can be started in two ways: whl package and Python script. The whl package form is more convenient to start, and the python script to start is convenient for secondary development.
Windows
pip install PPOCRLabel # install
# Select label mode and run
PPOCRLabel # [Normal mode] for [detection + recognition] labeling
PPOCRLabel --kie True # [KIE mode] for [detection + recognition + keyword extraction] labeling
If you getting this error
OSError: [WinError 126] The specified module could not be foundwhen you install shapely on windows. Please try to download Shapely whl file using http://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely.Reference: Solve shapely installation on windows
Ubuntu Linux
pip3 install PPOCRLabel
pip3 install trash-cli
# Select label mode and run
PPOCRLabel # [Normal mode] for [detection + recognition] labeling
PPOCRLabel --kie True # [KIE mode] for [detection + recognition + keyword extraction] labeling
MacOS
pip3 install PPOCRLabel
pip3 install opencv-contrib-python-headless==4.2.0.32
# Select label mode and run
PPOCRLabel # [Normal mode] for [detection + recognition] labeling
PPOCRLabel --kie True # [KIE mode] for [detection + recognition + keyword extraction] labeling
1.2.2 Run PPOCRLabel by Python Script
If you modify the PPOCRLabel file (for example, specifying a new built-in model), it will be more convenient to see the results by running the Python script. If you still want to start with the whl package, you need to uninstall the whl package in the current environment and then recompile it according to the next section.
cd ./PPOCRLabel # Switch to the PPOCRLabel directory
# Select label mode and run
python PPOCRLabel.py # [Normal mode] for [detection + recognition] labeling
python PPOCRLabel.py --kie True # [KIE mode] for [detection + recognition + keyword extraction] labeling
1.2.3 Build and Install the Whl Package Locally
Compile and install a new whl package, where 1.0.2 is the version number, you can specify the new version in 'setup.py'.
cd PaddleOCR/PPOCRLabel
python3 setup.py bdist_wheel
pip3 install dist/PPOCRLabel-1.0.2-py2.py3-none-any.whl
2. Usage
2.1 Steps
-
Build and launch using the instructions above.
-
Click 'Open Dir' in Menu/File to select the folder of the picture.<sup>[1]</sup>
-
Click 'Auto recognition', use PP-OCR model to automatically annotate images which marked with 'X' <sup>[2]</sup>before the file name.
-
Create Box:
4.1 Click 'Create RectBox' or press 'W' in English keyboard mode to draw a new rectangle detection box. Click and release left mouse to select a region to annotate the text area.
4.2 Press 'Q' to enter four-point labeling mode which enables you to create any four-point shape by clicking four points with the left mouse button in succession and DOUBLE CLICK the left mouse as the signal of labeling completion.
-
After the marking frame is drawn, the user clicks "OK", and the detection frame will be pre-assigned a "TEMPORARY" label.
-
Click 're-Recognition', model will rewrite ALL recognition results in ALL detection box<sup>[3]</sup>.
-
Single click the result in 'recognition result' list to manually change inaccurate recognition results.
-
Click "Check", the image status will switch to "√",then the program automatically jump to the next.
-
Click "Delete Image", and the image will be deleted to the recycle bin.
-
Labeling result: the user can export the label result manually through the menu "File - Export Label", while the program will also export automatically if "File - Auto export Label Mode" is selected. The manually checked label will be stored in Label.txt under the opened picture folder. Click "File"-"Export Recognition Results" in the menu bar, the recognition training data of such pictures will be saved in the crop_img folder, and the recognition label will be saved in rec_gt.txt<sup>[4]</sup>.
2.2 Table Annotation
The table annotation is aimed at extracting the structure of the table in a picture and converting it to Excel format, so the annotation needs to be done simultaneously with external software to edit Excel. In PPOCRLabel, complete the text information labeling (text and position), complete the table structure information labeling in the Excel file, the recommended steps are:
-
Table annotation: After opening the table picture, click on the
Table Recognitionbutton in the upper right corner of PPOCRLabel, which will call the table recognition model in PP-Structure to automatically label the table and pop up Excel at the same time. -
Change the recognition result: label each cell (i.e. the text in a cell is marked as a box). Right click on the box and click on
Cell Re-recognition. You can use the model to automatically recognise the text within a cell. -
Mark the table structure: for each cell contains the text, mark as any identifier (such as
1) in Excel, to ensure that the merged cell structure is same as the original picture. -
Export JSON format annotation: close all Excel files corresponding to table images, click
File-Export table JSON annotationto obtain JSON annotation results.
2.3 Note
[1] PPOCRLabel uses the opened folder as the project. After opening the image folder, the picture will not be displayed in the dialog. Instead, the pictures under the folder will be directly imported into the program after clicking "Open Dir".
[2] The image status indicates whether the user has saved the image manually. If it has not been saved manually it is "X", otherwise it is "√", PPOCRLabel will not relabel pictures with a status of "√".
[3] After clicking "Re-recognize", the model will overwrite ALL recognition results in the picture. Therefore, if the recognition result has been manually changed before, it may change afte
Related Skills
openhue
335.8kControl Philips Hue lights and scenes via the OpenHue CLI.
sag
335.8kElevenLabs text-to-speech with mac-style say UX.
weather
335.8kGet current weather and forecasts via wttr.in or Open-Meteo
tweakcc
1.4kCustomize Claude Code's system prompts, create custom toolsets, input pattern highlighters, themes/thinking verbs/spinners, customize input box & user message styling, support AGENTS.md, unlock private/unreleased features, and much more. Supports both native/npm installs on all platforms.
