Skip to content

Repository files navigation

OCR-D Pipeline for ECPO

Work in Progress

Prerequisites

  • Python ==3.10 (others might work, but this is what we tested. Very recent versions do not work.)

Pipeline overview

Our pipeline consists of the following steps:

  • eynollah-inference: Run Eynollah inference to get layout segmentation results from a fine-tuned Eynollah model. See this training/fine-tuning instruction for the details on our fine-tuned models.
  • ecpo-segment: Refine the layout segmentation results from Eynollah using PaddleOCR's layout analysis model.
  • ecpo-ocr: Run OCR on the text regions obtained from the previous step using VLLM.

Installation

  1. Clone the repository
git clone https://github.com/ssciwr/ecpo_ocrd.git
cd ecpo_ocrd
  1. To install the repository's dependencies, there are two options, please choose just one of them:
  • eynollah-gpu: for running Eynollah inference with GPU support (requires CUDA and cuDNN)
  • non-eynollah-gpu: for running non-GPU-Eynollah processes (e.g. Eynollah on CPU or PaddleOCR)

For example, to install the dependencies for running the eynollah-inference and ecpo-segment with CPU , use:

python -m pip install .[non-eynollah-gpu]
  1. Then install relevant OCR-D tools with:
ecpo_ocrd install

Usage

Before doing anything, add the bin folder to PATH:

export PATH=$PWD/bin:$PATH

Then, create an OCR-D workspace for your data via:

mkdir myworkspace
cd myworkspace
ecpo_ocrd workspace create

For details, please have a look at ecpo_ocrd workspace create --help. For testing purposed, you should always add --sample n with a reasonably small n (otherwise you will process the entire subcorpus for the selected data source).

Then, you can run any of the provided workflow shell scripts e.g.

../workflows/jingbao.sh

Running the pipeline with GPUs

Dependencies for Eynollah inference and PaddleOCR are mutually exclusive due to numpy version.

To utilize GPU for Eynollah process, the following dependencies should be installed:

  • Python 3.10
  • CUDA 11.8
  • cuDNN 8.6
  • TensorFlow 2.12.0

So far, we can only create a conda environment with the above settings. Therefore, even though we already created envs and bin folders with ecpo_ocrd install, we still need to use conda environments to run Eynollah-related processes.

A quick-and-dirty solution to run the whole pipeline with GPU is to create two conda environments, one for Eynollah and one for the rest of the pipeline.

Eynollah conda environment

  1. Use this instruction to setup a conda environment, named e.g. ecpo_eynollah, with the specified Python, CUDA, cuDNN, and TensorFlow versions.

  2. Install the Eynollah-related dependencies in this environment with:

pip install .[eynollah-gpu]

Non-Eynollah conda environment

Create the second conda environment and install dependencies for the rest of the pipeline with:

conda create -n ecpo_non_eynollah python=3.10
conda activate ecpo_non_eynollah
pip install .[non-eynollah-gpu]

Run the parallel script

After setting up the two conda environments and finishing the installation above, move to the root folder of the repository (ecpo_ocrd) and run the parallel script up to the ecpo-segment step with:

# assuming you are in the repository root
./workflows/jingbao_parallel_eynollah_paddle.sh <path_to_workspace> <eynollah_conda_env> <non_eynollah_conda_env>

To run the last step ecpo-ocr with VLLM: TBU.

About

An OCR-D Pipeline for ECPO

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages