-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the wikimedia-ocr wiki!
This documentation is work in progress and still very incomplete.
A local installation allows using Open Source OCR without depending on the Wikimedia OCR service. In addition it allows more OCR languages or models and testing of new software features.
The installation is possible on all major operating systems.
The instructions here install a fork of the official Wikimedia code. That fork adds kraken with several segmentation and OCR models as an additional free OCR engine which works with printed and handwritten documents. It also adds OCR models for OCR of historic prints with the Tesseract OCR engine.
The instructions assume an installation in $HOME/wikimedia-ocr
, but any other installation directory is possible, too.
The installation is based on Debian GNU Linux (stable). Similar instructions should also work for Linux Mint, Ubuntu and other similar Linux distributions.
# Install JSON processor.
sudo apt install jq
# Install command line interface for Symfony.
curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | sudo -E bash
sudo apt install symfony-cli
# Install graphicsmagick (required for cropping with kraken).
sudo apt install graphicsmagick
# Install Tesseract with OCR models ("languages").
sudo apt install tesseract-ocr-all
sudo mkdir -p /usr/share/tesseract-ocr/5/tessdata/ubma
(cd /usr/share/tesseract-ocr/5/tessdata/ubma && sudo wget https://ub-backup.bib.uni-mannheim.de/~stweil/tesstrain/frak2021/tessdata_fast/frak2021_0.905.traineddata)
# Install package managers composer for PHP and npm for Node.js.
sudo apt install composer npm
# Clone wikimedia-ocr with kraken OCR engine.
git clone --branch kraken https://github.com/stweil/wikimedia-ocr.git $HOME/wikimedia-ocr
# Install kraken in a virtual Python environment.
sudo apt install python3-venv
cd $HOME/wikimedia-ocr
python3 -m venv ../venv
source ../venv/bin/activate
pip install -U pip setuptools kraken
For development, run these commands:
# Install and build for development.
cd $HOME/wikimedia-ocr
composer install --dev
npm install
npm run dev
For production, run these commands:
# Install and build for production.
cd $HOME/wikimedia-ocr
composer install
npm install
npm run build
cd $HOME/wikimedia-ocr
symfony server:start
The wikimedia-ocr is then available on http://127.0.0.1:8000/.
The installation uses Homebrew to get some of the required software packages.
# Install JSON processor.
brew install jq
# Install command line interface for Symfony.
brew install symfony-cli/tap/symfony-cli
# Install graphicsmagick (required for cropping with kraken).
brew install graphicsmagick
# Install Tesseract with OCR models ("languages").
brew install tesseract-lang
ln -siv script/Fraktur.traineddata $HOMEBREW_PREFIX/share/tessdata
ln -siv script/Greek.traineddata $HOMEBREW_PREFIX/share/tessdata
ln -siv script/Latin.traineddata $HOMEBREW_PREFIX/share/tessdata
sudo mkdir -p /usr/share/tesseract-ocr/5/tessdata/ubma
(cd /usr/share/tesseract-ocr/5/tessdata/ubma && sudo wget https://ub-backup.bib.uni-mannheim.de/~stweil/tesstrain/frak2021/tessdata_fast/frak2021_0.905.traineddata)
# Clone wikimedia-ocr with kraken OCR engine.
git clone --branch kraken https://github.com/stweil/wikimedia-ocr.git $HOME/wikimedia-ocr
# Install kraken in a virtual Python environment.
cd $HOME/wikimedia-ocr
python3 -m venv ../venv
source ../venv/bin/activate
pip install -U pip setuptools kraken
For development, run these commands:
# Install and build for development.
cd $HOME/wikimedia-ocr
composer install --dev
npm install
npm run dev
For production, run these commands:
# Install and build for production.
cd $HOME/wikimedia-ocr
composer install
npm install
npm run build
cd $HOME/wikimedia-ocr
symfony server:start
The wikimedia-ocr is then available on http://127.0.0.1:8000/.
Windows users can use Microsoft's Windows Subsystem for Linux (WSL) to get a Linux environment which runs under Windows. Then the instructions for Linux can be applied.