Work in Progress
- Python
==3.10(others might work, but this is what we tested. Very recent versions do not work.)
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.
- Clone the repository
git clone https://github.com/ssciwr/ecpo_ocrd.git
cd ecpo_ocrd- 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]- Then install relevant OCR-D tools with:
ecpo_ocrd installBefore doing anything, add the bin folder to PATH:
export PATH=$PWD/bin:$PATHThen, create an OCR-D workspace for your data via:
mkdir myworkspace
cd myworkspace
ecpo_ocrd workspace createFor 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.shDependencies for Eynollah inference and PaddleOCR are mutually exclusive due to numpy version.
To utilize GPU for Eynollah process, the following dependencies should be installed:
Python3.10CUDA11.8cuDNN8.6TensorFlow2.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.
-
Use this instruction to setup a
condaenvironment, named e.g.ecpo_eynollah, with the specified Python, CUDA, cuDNN, and TensorFlow versions. -
Install the Eynollah-related dependencies in this environment with:
pip install .[eynollah-gpu]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]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.