# breta01/handwriting-ocr architecture

> Architecture diagram of the GitHub repository breta01/handwriting-ocr, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/breta01/handwriting-ocr
- Repository: https://github.com/breta01/handwriting-ocr

## Overview

Handwriting OCR is a notebook-driven system for turning page photographs into recognized handwritten text, including Czech. The documented workflow detects and crops the page, separates words, normalizes them, then segments and recognizes characters (or words). The OCR notebook is documented as combining these stages; specific notebook-to-notebook calls are not shown. The graph also preserves the substantial dataset preparation and OCR runtime modules named in the source index. Notebook internals and several subsystem connections were not sampled, so those links are omitted rather than inferred.

Main entry points: [`src/data/data_extractor.py`](https://github.com/breta01/handwriting-ocr/blob/master/src/data/data_extractor.py) (Dataset extraction), [`notebooks/OCR.ipynb`](https://github.com/breta01/handwriting-ocr/blob/master/notebooks/OCR.ipynb) (OCR workflow), [`notebooks/page_detection.ipynb`](https://github.com/breta01/handwriting-ocr/blob/master/notebooks/page_detection.ipynb) (Page detection), [`notebooks/word_detection.ipynb`](https://github.com/breta01/handwriting-ocr/blob/master/notebooks/word_detection.ipynb) (Word detection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_recognition["Recognition workflow"]
  node_page_detect["Page detection"]
  node_word_detect["Word detection"]
  node_word_preprocess["Word preprocessing"]
  node_ocr_flow["OCR workflow<br/>[OCR.ipynb]"]
  node_ocr_eval["OCR evaluator"]
  node_char_segment["Character segmentation"]
  node_char_birnn["BiRNN segmentation"]
  node_char_cnn["CNN segmentation"]
  node_char_experimental["Experimental segmentation"]
  node_char_classifier_cnn["CNN character classifier"]
  node_char_classifier_rnn["RNN character classifier"]
  node_word_ctc["CTC word recognition"]
  node_word_seq2seq["Seq2seq word recognition"]
  node_word_seq2seqx["Seq2seq variant"]
end

subgraph group_runtime["OCR runtime"]
  node_word_normalization["Word normalization<br/>[normalization.py]"]
  node_ocr_datahelpers["OCR data helpers<br/>[datahelpers.py]"]
  node_ocr_iterator["Data iterator<br/>[dataiterator.py]"]
  node_ocr_characters["Character utilities<br/>[characters.py]"]
  node_ocr_words["Word utilities<br/>[words.py]"]
  node_ocr_tfhelpers["TensorFlow helpers<br/>[tfhelpers.py]"]
end

subgraph group_data["Dataset preparation"]
  node_data_extractor["Dataset extraction<br/>[data_extractor.py]"]
  node_breta["Breta dataset adapter<br/>[breta.py]"]
  node_camb["CAMB dataset adapter<br/>[camb.py]"]
  node_cvl["CVL dataset adapter<br/>[cvl.py]"]
  node_iam["IAM dataset adapter<br/>[iam.py]"]
  node_orand["ORAND dataset adapter<br/>[orand.py]"]
  node_data_normalization["Word data normalization"]
  node_data_sets["Train/test splitting"]
  node_create_csv["CSV conversion<br/>[create_csv.py]"]
  node_gapline_labeling["Gapline labeling<br/>[WordClassDM.py]"]
end

subgraph group_models["Model artifacts"]
  node_freeze_graph["Graph freezing<br/>[freeze_graph.py]"]
  node_graph_optimizer["Graph optimization<br/>[graph_optimizer.py]"]
end

node_user(("Page photograph"))

node_user -->|"submits photo"| node_page_detect
node_page_detect -->|"then detects words"| node_word_detect
node_word_detect -->|"then separates words"| node_word_preprocess
node_word_preprocess -->|"then normalizes"| node_char_segment
node_ocr_flow -->|"combines stages"| node_page_detect
node_ocr_flow -->|"combines stages"| node_word_detect
node_ocr_flow -->|"combines stages"| node_word_preprocess
node_ocr_flow -->|"combines stages"| node_char_segment
node_data_extractor -->|"dispatches extraction"| node_breta
node_data_extractor -->|"dispatches extraction"| node_camb
node_data_extractor -->|"dispatches extraction"| node_cvl
node_data_extractor -->|"dispatches extraction"| node_iam
node_data_extractor -->|"dispatches extraction"| node_orand
node_data_normalization -->|"uses dataset registry"| node_data_extractor
node_data_normalization -->|"normalizes images"| node_word_normalization
node_data_sets -->|"uses dataset registry"| node_data_extractor
node_data_sets -->|"optionally converts"| node_create_csv
node_gapline_labeling -->|"normalizes input"| node_word_normalization
node_ocr_iterator -->|"uses helpers"| node_ocr_datahelpers
node_ocr_characters -->|"uses helpers"| node_ocr_tfhelpers
node_ocr_words -.->|"normalizes words"| node_word_normalization
node_graph_optimizer -->|"references freezing"| node_freeze_graph

click node_page_detect "https://github.com/breta01/handwriting-ocr/blob/master/notebooks/page_detection.ipynb"
click node_word_detect "https://github.com/breta01/handwriting-ocr/blob/master/notebooks/word_detection.ipynb"
click node_word_preprocess "https://github.com/breta01/handwriting-ocr/blob/master/notebooks/word_preprocessing.ipynb"
click node_ocr_flow "https://github.com/breta01/handwriting-ocr/blob/master/notebooks/OCR.ipynb"
click node_ocr_eval "https://github.com/breta01/handwriting-ocr/blob/master/notebooks/ocr_evaluator.ipynb"
click node_char_segment "https://github.com/breta01/handwriting-ocr/blob/master/char_segmentation.ipynb"
click node_char_birnn "https://github.com/breta01/handwriting-ocr/blob/master/char_segmentation_BiRNN.ipynb"
click node_char_cnn "https://github.com/breta01/handwriting-ocr/blob/master/char_segmentation_CNN.ipynb"
click node_char_experimental "https://github.com/breta01/handwriting-ocr/blob/master/char_segmentation_experimental.ipynb"
click node_char_classifier_cnn "https://github.com/breta01/handwriting-ocr/blob/master/char_classifier_CNN.ipynb"
click node_char_classifier_rnn "https://github.com/breta01/handwriting-ocr/blob/master/char_classifier_RNN.ipynb"
click node_word_ctc "https://github.com/breta01/handwriting-ocr/blob/master/word_classifier_CTC.ipynb"
click node_word_seq2seq "https://github.com/breta01/handwriting-ocr/blob/master/word_classifier_seq2seq.ipynb"
click node_word_seq2seqx "https://github.com/breta01/handwriting-ocr/blob/master/word_classifier_seq2seqX.ipynb"
click node_word_normalization "https://github.com/breta01/handwriting-ocr/blob/master/src/ocr/normalization.py"
click node_ocr_datahelpers "https://github.com/breta01/handwriting-ocr/blob/master/src/ocr/datahelpers.py"
click node_ocr_iterator "https://github.com/breta01/handwriting-ocr/blob/master/src/ocr/dataiterator.py"
click node_ocr_characters "https://github.com/breta01/handwriting-ocr/blob/master/src/ocr/characters.py"
click node_ocr_words "https://github.com/breta01/handwriting-ocr/blob/master/src/ocr/words.py"
click node_ocr_tfhelpers "https://github.com/breta01/handwriting-ocr/blob/master/src/ocr/tfhelpers.py"
click node_data_extractor "https://github.com/breta01/handwriting-ocr/blob/master/src/data/data_extractor.py"
click node_breta "https://github.com/breta01/handwriting-ocr/blob/master/src/data/datasets/breta.py"
click node_camb "https://github.com/breta01/handwriting-ocr/blob/master/src/data/datasets/camb.py"
click node_cvl "https://github.com/breta01/handwriting-ocr/blob/master/src/data/datasets/cvl.py"
click node_iam "https://github.com/breta01/handwriting-ocr/blob/master/src/data/datasets/iam.py"
click node_orand "https://github.com/breta01/handwriting-ocr/blob/master/src/data/datasets/orand.py"
click node_data_normalization "https://github.com/breta01/handwriting-ocr/blob/master/src/data/data_normalization.py"
click node_data_sets "https://github.com/breta01/handwriting-ocr/blob/master/src/data/data_create_sets.py"
click node_create_csv "https://github.com/breta01/handwriting-ocr/blob/master/src/data/create_csv.py"
click node_gapline_labeling "https://github.com/breta01/handwriting-ocr/blob/master/src/data/data_creation/WordClassDM.py"
click node_freeze_graph "https://github.com/breta01/handwriting-ocr/blob/master/models/freeze_graph.py"
click node_graph_optimizer "https://github.com/breta01/handwriting-ocr/blob/master/models/graph_optimizer.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_page_detect,node_word_detect,node_word_preprocess,node_ocr_flow,node_ocr_eval,node_char_segment,node_char_birnn,node_char_cnn,node_char_experimental,node_char_classifier_cnn,node_char_classifier_rnn,node_word_ctc,node_word_seq2seq,node_word_seq2seqx toneBlue
class node_word_normalization,node_ocr_datahelpers,node_ocr_iterator,node_ocr_characters,node_ocr_words,node_ocr_tfhelpers toneAmber
class node_data_extractor,node_breta,node_camb,node_cvl,node_iam,node_orand,node_data_normalization,node_data_sets,node_create_csv,node_gapline_labeling toneMint
class node_freeze_graph,node_graph_optimizer toneRose
class node_user toneIndigo
```

## Components

### Recognition workflow

- [Page detection](https://github.com/breta01/handwriting-ocr/blob/master/notebooks/page_detection.ipynb): `notebooks/page_detection.ipynb`
- [Word detection](https://github.com/breta01/handwriting-ocr/blob/master/notebooks/word_detection.ipynb): `notebooks/word_detection.ipynb`
- [Word preprocessing](https://github.com/breta01/handwriting-ocr/blob/master/notebooks/word_preprocessing.ipynb): `notebooks/word_preprocessing.ipynb`
- [OCR workflow](https://github.com/breta01/handwriting-ocr/blob/master/notebooks/OCR.ipynb): `notebooks/OCR.ipynb`
- [OCR evaluator](https://github.com/breta01/handwriting-ocr/blob/master/notebooks/ocr_evaluator.ipynb): `notebooks/ocr_evaluator.ipynb`
- [Character segmentation](https://github.com/breta01/handwriting-ocr/blob/master/char_segmentation.ipynb): `char_segmentation.ipynb`
- [BiRNN segmentation](https://github.com/breta01/handwriting-ocr/blob/master/char_segmentation_BiRNN.ipynb): `char_segmentation_BiRNN.ipynb`
- [CNN segmentation](https://github.com/breta01/handwriting-ocr/blob/master/char_segmentation_CNN.ipynb): `char_segmentation_CNN.ipynb`
- [Experimental segmentation](https://github.com/breta01/handwriting-ocr/blob/master/char_segmentation_experimental.ipynb): `char_segmentation_experimental.ipynb`
- [CNN character classifier](https://github.com/breta01/handwriting-ocr/blob/master/char_classifier_CNN.ipynb): `char_classifier_CNN.ipynb`
- [RNN character classifier](https://github.com/breta01/handwriting-ocr/blob/master/char_classifier_RNN.ipynb): `char_classifier_RNN.ipynb`
- [CTC word recognition](https://github.com/breta01/handwriting-ocr/blob/master/word_classifier_CTC.ipynb): `word_classifier_CTC.ipynb`
- [Seq2seq word recognition](https://github.com/breta01/handwriting-ocr/blob/master/word_classifier_seq2seq.ipynb): `word_classifier_seq2seq.ipynb`
- [Seq2seq variant](https://github.com/breta01/handwriting-ocr/blob/master/word_classifier_seq2seqX.ipynb): `word_classifier_seq2seqX.ipynb`

### OCR runtime

- [Word normalization](https://github.com/breta01/handwriting-ocr/blob/master/src/ocr/normalization.py): `src/ocr/normalization.py`
- [OCR data helpers](https://github.com/breta01/handwriting-ocr/blob/master/src/ocr/datahelpers.py): `src/ocr/datahelpers.py`
- [Data iterator](https://github.com/breta01/handwriting-ocr/blob/master/src/ocr/dataiterator.py): `src/ocr/dataiterator.py`
- [Character utilities](https://github.com/breta01/handwriting-ocr/blob/master/src/ocr/characters.py): `src/ocr/characters.py`
- [Word utilities](https://github.com/breta01/handwriting-ocr/blob/master/src/ocr/words.py): `src/ocr/words.py`
- [TensorFlow helpers](https://github.com/breta01/handwriting-ocr/blob/master/src/ocr/tfhelpers.py): `src/ocr/tfhelpers.py`

### Dataset preparation

- [Dataset extraction](https://github.com/breta01/handwriting-ocr/blob/master/src/data/data_extractor.py): `src/data/data_extractor.py`
- [Breta dataset adapter](https://github.com/breta01/handwriting-ocr/blob/master/src/data/datasets/breta.py): `src/data/datasets/breta.py`
- [CAMB dataset adapter](https://github.com/breta01/handwriting-ocr/blob/master/src/data/datasets/camb.py): `src/data/datasets/camb.py`
- [CVL dataset adapter](https://github.com/breta01/handwriting-ocr/blob/master/src/data/datasets/cvl.py): `src/data/datasets/cvl.py`
- [IAM dataset adapter](https://github.com/breta01/handwriting-ocr/blob/master/src/data/datasets/iam.py): `src/data/datasets/iam.py`
- [ORAND dataset adapter](https://github.com/breta01/handwriting-ocr/blob/master/src/data/datasets/orand.py): `src/data/datasets/orand.py`
- [Word data normalization](https://github.com/breta01/handwriting-ocr/blob/master/src/data/data_normalization.py): `src/data/data_normalization.py`
- [Train/test splitting](https://github.com/breta01/handwriting-ocr/blob/master/src/data/data_create_sets.py): `src/data/data_create_sets.py`
- [CSV conversion](https://github.com/breta01/handwriting-ocr/blob/master/src/data/create_csv.py): `src/data/create_csv.py`
- [Gapline labeling](https://github.com/breta01/handwriting-ocr/blob/master/src/data/data_creation/WordClassDM.py): `src/data/data_creation/WordClassDM.py`

### Model artifacts

- [Graph freezing](https://github.com/breta01/handwriting-ocr/blob/master/models/freeze_graph.py): `models/freeze_graph.py`
- [Graph optimization](https://github.com/breta01/handwriting-ocr/blob/master/models/graph_optimizer.py): `models/graph_optimizer.py`

### Other components

- **Page photograph**

## Connections

- Page photograph → Page detection: submits photo (evidence: `README.md`)
- Page detection → Word detection: then detects words (evidence: `README.md`)
- Word detection → Word preprocessing: then separates words (evidence: `README.md`)
- Word preprocessing → Character segmentation: then normalizes (evidence: `README.md`)
- OCR workflow → Page detection: combines stages (evidence: `README.md`)
- OCR workflow → Word detection: combines stages (evidence: `README.md`)
- OCR workflow → Word preprocessing: combines stages (evidence: `README.md`)
- OCR workflow → Character segmentation: combines stages (evidence: `README.md`)
- Dataset extraction → Breta dataset adapter: dispatches extraction (evidence: `src/data/data_extractor.py`)
- Dataset extraction → CAMB dataset adapter: dispatches extraction (evidence: `src/data/data_extractor.py`)
- Dataset extraction → CVL dataset adapter: dispatches extraction (evidence: `src/data/data_extractor.py`)
- Dataset extraction → IAM dataset adapter: dispatches extraction (evidence: `src/data/data_extractor.py`)
- Dataset extraction → ORAND dataset adapter: dispatches extraction (evidence: `src/data/data_extractor.py`)
- Word data normalization → Dataset extraction: uses dataset registry (evidence: `src/data/data_normalization.py`)
- Word data normalization → Word normalization: normalizes images (evidence: `src/data/data_normalization.py`)
- Train/test splitting → Dataset extraction: uses dataset registry (evidence: `src/data/data_create_sets.py`)
- Train/test splitting → CSV conversion: optionally converts (evidence: `src/data/data_create_sets.py`)
- Gapline labeling → Word normalization: normalizes input (evidence: `src/data/data_creation/WordClassDM.py`)
- Data iterator → OCR data helpers: uses helpers (evidence: `src/ocr/dataiterator.py`)
- Character utilities → TensorFlow helpers: uses helpers (evidence: `src/ocr/characters.py`)
- Word utilities → Word normalization: normalizes words
- Graph optimization → Graph freezing: references freezing (evidence: `models/graph_optimizer.py`)
