mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/ocr.git
synced 2024-12-26 15:54:19 +00:00
93 lines
3.0 KiB
Markdown
93 lines
3.0 KiB
Markdown
# OCR - Optical Character Recognition
|
|
|
|
This software implements a heavily parallelized pipeline to recognize text in PDF files. It is used for nopaque's OCR service but you can also use it standalone, for that purpose a convenient wrapper script is provided.
|
|
|
|
## Software used in this pipeline implementation
|
|
|
|
- Official Debian Docker image (buster-slim): https://hub.docker.com/_/debian
|
|
- Software from Debian Buster's free repositories
|
|
- ocropy (1.3.3): https://github.com/ocropus/ocropy/releases/tag/v1.3.3
|
|
- pyFlow (1.1.20): https://github.com/Illumina/pyflow/releases/tag/v1.1.20
|
|
- Tesseract OCR (4.1.1): https://github.com/tesseract-ocr/tesseract/releases/tag/4.1.1
|
|
- tessdata_best (4.1.0): https://github.com/tesseract-ocr/tessdata_best/releases/tag/4.1.0
|
|
|
|
## Use this image
|
|
|
|
1. Create input and output directories for the pipeline.
|
|
``` bash
|
|
mkdir -p /<my_data_location>/input /<my_data_location>/output
|
|
```
|
|
|
|
2. Place your PDF files inside `/<my_data_location>/input`. Files should all contain text of the same language.
|
|
|
|
3. Start the pipeline process. Check the [Pipeline arguments](#pipeline-arguments) section for more details.
|
|
```
|
|
# Option one: Use the wrapper script
|
|
## Install the wrapper script (only on first run). Get it from https://gitlab.ub.uni-bielefeld.de/sfb1288inf/ocr/-/raw/development/wrapper/ocr, make it executeable and add it to your ${PATH}
|
|
cd /<my_data_location>
|
|
ocr -i input -l <language_code> -o output <optional_pipeline_arguments>
|
|
|
|
# Option two: Classic Docker style
|
|
docker run \
|
|
--rm \
|
|
-it \
|
|
-u $(id -u $USER):$(id -g $USER) \
|
|
-v /<my_data_location>/input:/input \
|
|
-v /<my_data_location>/output:/output \
|
|
gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/ocr:development \
|
|
-i /ocr_pipeline/input \
|
|
-l <language_code> \
|
|
-o /ocr_pipeline/output \
|
|
<optional_pipeline_arguments>
|
|
```
|
|
|
|
4. Check your results in the `/<my_data_location>/output` directory.
|
|
|
|
### Pipeline arguments
|
|
|
|
#### Mandatory arguments
|
|
|
|
`-i, --input-dir INPUT_DIR`
|
|
* Input directory
|
|
|
|
`-o, --output-dir OUTPUT_DIR`
|
|
* Output directory
|
|
|
|
`-l, --language {spa,fra,dan,deu,eng,frm,chi_tra,ara,enm,ita,ell,frk,rus,por}`
|
|
* Language of the input (3-character ISO 639-2 language codes)
|
|
|
|
#### Optional arguments
|
|
|
|
`--binarize`
|
|
* Add binarization as a preprocessing step
|
|
|
|
`--log-dir`
|
|
* Logging directory
|
|
|
|
`--mem-mb`
|
|
* Amount of system memory to be used (Default: min(--n-cores * 2048, available system memory))
|
|
|
|
`--n-cores`
|
|
* Number of CPU threads to be used (Default: min(4, available CPU cores))
|
|
|
|
`-v, --version`
|
|
* Returns the current version of the OCR pipeline
|
|
|
|
``` bash
|
|
# Example with all arguments used
|
|
docker run \
|
|
--rm \
|
|
-it \
|
|
-u $(id -u $USER):$(id -g $USER) \
|
|
-v /<my_data_location>/input:/ocr_pipeline/input \
|
|
-v /<my_data_location>/output:/ocr_pipeline/output \
|
|
-v /<my_data_location>/logs:/ocr_pipeline/logs \
|
|
gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/ocr:development \
|
|
-i /ocr_pipeline/input \
|
|
-l eng \
|
|
-o /ocr_pipeline/output \
|
|
--binarize \
|
|
--log-dir /ocr_pipeline/logs \
|
|
--n-cores 8 \
|
|
```
|