To check your CUDA version, run:
nvidia-smion both Windows and Linux systems. Depending on the version, select the appropriate OCR module version according to the instructions in the rest of the README.
Conda is used here, but you can also use venv:
cd ~/PycharmProjects
git clone <repo_link> <target_folder_name>
cd <target_folder_name>
conda create -n django_test python=3.12.9
conda activate django_testconda install -c conda-forge nodejs=22.13python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu118/python -m pip install paddlepaddle-gpu==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/pip install -r requirements.txt
cd frontend && npm install && npm run build
cd ..Create .env files and add the appropriate environment variables. The contents of both .env files are available on the internal channel. Adjust path structures to your operating system.
cd ocr
nano .env
# (...) fill in ocr/.env
Unfilled contents of ocr/.env:
bashSECRET_KEY=
UPLOADED_FILES=
FIREBASE_KEY=
GOOGLE_OAUTH2_CLIENT_ID=
GOOGLE_OAUTH2_CLIENT_SECRET=
GOOGLE_OAUTH2_REDIRECT_URI=
And the second .env:
bashcd ../frontend
nano .env
# (...) fill in frontend/.envUnfilled contents of frontend/.env:
REACT_APP_GOOGLE_OAUTH2_CLIENT_ID=
REACT_APP_FIREBASE_KEY=
REACT_APP_TYPE=
REACT_APP_PROJECT_ID=
REACT_APP_PRIVATE_KEY_ID=
REACT_APP_PRIVATE_KEY=
REACT_APP_CLIENT_EMAIL=
REACT_APP_CLIENT_ID=
REACT_APP_AUTH_URI=
REACT_APP_TOKEN_URI=
REACT_APP_AUTH_PROVIDER_X509_CERT_URL=
REACT_APP_CLIENT_X509_CERT_URL=
REACT_APP_UNIVERSE_DOMAIN=Now you need to generate and set up certificates. After running the commands, fill in the answers to questions in the terminal (location, email, etc.) Windows
cd ..
./certgen.ps1Linux
cd ..
openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365Final steps to run the application:
python ocr/manage.py collectstatic --noinput
python ocr/manage.py migratemake sure you're in the project root directory
python ocr/manage.py runserver_plus --cert-file cert.pem --key-file key.pem 0.0.0.0:8000- (dev) Change your project interpreter in PyCharm to django_test:

- (dev) Generating and setting new keys A new SECRET_KEY can be generated using the command:
django-admin shellrun in an environment where Django is installed (see official tutorial). Enter:
from django.core.management.utils import get_random_secret_key
get_random_secret_key()in the shell you just launched to get a new private key for Django. A ready .env file and Firebase json are available on the internal channel, but you can generate your own keys. Firebase json can be found at:
https://console.firebase.google.com/u/0/project/io2025-d859f/overviewby going to the tab:
Project settings -> Service accounts -> Generate new private key`Google variables can be found in:
Google Cloud Services -> Google Auth Platform (best to search in the search bar at the top) -> ClientsThere we can select a client and add/edit things like redirect url.
- (dev) Test data for the model Currently, we're interested in the first two datasets.
#IAM dataset for validation and testing (both links require login)
https://www.kaggle.com/datasets/ngkinwang/iam-dataset
https://fki.tic.heia-fr.ch/DBs/iamDB/data/lines.tgzFor fine-tuning:
#Polish handwritten letters dataset for fine-tuning
https://www.kaggle.com/datasets/westedcrean/phcd-polish-handwritten-characters-databasePlace the archives to have the following structure:
model/
├── modelbase.py
├── trocr.py
├── (...)
├── archive.zip #Kaggle
├── lines.tgz #FKI
└── setup_datasets.shThen run the ./setup_datasets.sh script from the model/ directory.
- Running tests Automatically: From the application root folder, run run_tests.ps1
First terminal:
cd frontend
npm startSecond terminal:
cd ocr
coverage erase
coverage run --rcfile=.coveragerc manage.py test
coverage html
start htmlcov/index.html