This module implements a page segmentation algorithm based on a Fully Convolutional Network (FCN). The FCN creates a classification for each pixel in a binary image. This result is then segmented per class using XY cuts.
- For GPU-Support: CUDA and CUDNN
- other requirements are installed via Makefile / pip, see
requirements.txt
in repository root.
make deps
to install dependencies and
make install
to install the package.
Both install python packages via pip, so you may want to activate a virtalenv before installing.
If you share a virtualenv with a package requiring tensorflow < 2.1 and want to
use a GPU, replace the tensorflow
package with tensorflow-gpu
manually.
ocrd-pc-segmentation
follows the ocrd CLI.
It expects a binary page image and produces region entries in the PageXML file.
The following parameters are recognized in the JSON parameter file:
overwrite_regions
: remove previously existing text regionsxheight
: height of character "x" in pixels used during training.model
: pixel-classifier model path. The special values__DEFAULT__
and__LEGACY__
load the bundled default model or previous default model respectively.gpu_allow_growth
: required for GPU use with some graphic cards (set to true, if you get CUDNN_INTERNAL_ERROR)resize_height
: scale down pixelclassifier output to this height before postprocessing. Independent of training / used model. (performance / quality tradeoff, defaults to 300)
There is a simple CLI test, that will run the tool on a single image from the assets repository.
make test-cli
To train models for the pixel classifier, see its README