# ioannisdev/image_to_text_-ocr- architecture

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

- Interactive diagram: https://gitdiagram.com/ioannisdev/image_to_text_-ocr-
- Repository: https://github.com/ioannisdev/image_to_text_-ocr-

## Overview

This repository is a prototype OCR system: a camera demo supplies frames to a two-stage text detector and recognizer, which returns words and reading-order text for display. The graph separates the runtime workflow from model definitions and the training-data input. Source excerpts show the camera loop, pipeline setup, detector, and model architecture; some pipeline details and the dataset’s consumers were not shown, so those connections are omitted.

Main entry points: [`model/proto_inference.py`](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/proto_inference.py) (Inference demo), [`model/ocr_pipeline.py`](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/ocr_pipeline.py) (Pipeline loader), [`data/charset.json`](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/data/charset.json) (Character set), [`model/model.py`](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/model.py) (DBNet detector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Camera OCR runtime"]
  node_camera["Camera frames"]
  node_inference["Inference demo<br/>[proto_inference.py]"]
  node_overlay["Annotated preview<br/>[proto_inference.py]"]
end

subgraph group_pipeline["OCR processing"]
  node_load["Pipeline loader<br/>[ocr_pipeline.py]"]
  node_preprocess["Image preparation<br/>[ocr_pipeline.py]"]
  node_detection["Text detection<br/>[ocr_pipeline.py]"]
  node_boxdecode["Box postprocessing<br/>[ocr_pipeline.py]"]
  node_crop["Word crops<br/>[ocr_pipeline.py]"]
  node_recognition["Word recognition<br/>[ocr_pipeline.py]"]
  node_ordering["Reading order<br/>[ocr_pipeline.py]"]
  node_result["OCR result<br/>[ocr_pipeline.py]"]
end

subgraph group_models["Models and data"]
  node_dbnet["DBNet detector<br/>[model.py]"]
  node_cnn["CNN feature extractor<br/>[model.py]"]
  node_transformer["Transformer head<br/>[model.py]"]
  node_charset["Character set<br/>[charset.json]"]
  node_checkpoints["Model checkpoints"]
  node_dataset["OCR training dataset<br/>[OCR_dataset.py]"]
end

node_operator(("Camera operator"))

node_operator -->|"provides input"| node_camera
node_camera -->|"supplies frames"| node_inference
node_inference -->|"loads pipeline"| node_load
node_inference -->|"configures model"| node_dbnet
node_inference -->|"configures model"| node_cnn
node_inference -->|"configures model"| node_transformer
node_inference -->|"reads character set"| node_charset
node_load -->|"loads weights"| node_checkpoints
node_load -->|"reads character set"| node_charset
node_load -->|"creates pipeline"| node_preprocess
node_preprocess -->|"prepares image"| node_detection
node_detection -->|"predicts regions"| node_dbnet
node_detection -->|"decodes probability map"| node_boxdecode
node_boxdecode -->|"yields word boxes"| node_crop
node_crop -->|"prepares word images"| node_recognition
node_recognition -->|"extracts features"| node_cnn
node_recognition -->|"predicts characters"| node_transformer
node_recognition -->|"decodes characters"| node_charset
node_ordering -->|"assembles lines"| node_result
node_inference -->|"requests OCR result"| node_ordering
node_result -->|"returns word boxes"| node_overlay
node_overlay -->|"shows preview"| node_operator

click node_inference "https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/proto_inference.py"
click node_overlay "https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/proto_inference.py"
click node_load "https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/ocr_pipeline.py"
click node_preprocess "https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/ocr_pipeline.py"
click node_detection "https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/ocr_pipeline.py"
click node_boxdecode "https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/ocr_pipeline.py"
click node_crop "https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/ocr_pipeline.py"
click node_recognition "https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/ocr_pipeline.py"
click node_ordering "https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/ocr_pipeline.py"
click node_result "https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/ocr_pipeline.py"
click node_dbnet "https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/model.py"
click node_cnn "https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/model.py"
click node_transformer "https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/model.py"
click node_charset "https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/data/charset.json"
click node_checkpoints "https://github.com/ioannisdev/image_to_text_-ocr-/tree/main/model_pt"
click node_dataset "https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/OCR_dataset.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_camera,node_inference,node_overlay toneBlue
class node_load,node_preprocess,node_detection,node_boxdecode,node_crop,node_recognition,node_ordering,node_result toneAmber
class node_dbnet,node_cnn,node_transformer,node_charset,node_checkpoints,node_dataset toneMint
class node_operator toneIndigo
```

## Components

### Camera OCR runtime

- **Camera frames**
- [Inference demo](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/proto_inference.py): `model/proto_inference.py`
- [Annotated preview](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/proto_inference.py): `model/proto_inference.py`

### OCR processing

- [Pipeline loader](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/ocr_pipeline.py): `model/ocr_pipeline.py`
- [Image preparation](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/ocr_pipeline.py): `model/ocr_pipeline.py`
- [Text detection](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/ocr_pipeline.py): `model/ocr_pipeline.py`
- [Box postprocessing](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/ocr_pipeline.py): `model/ocr_pipeline.py`
- [Word crops](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/ocr_pipeline.py): `model/ocr_pipeline.py`
- [Word recognition](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/ocr_pipeline.py): `model/ocr_pipeline.py`
- [Reading order](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/ocr_pipeline.py): `model/ocr_pipeline.py`
- [OCR result](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/ocr_pipeline.py): `model/ocr_pipeline.py`

### Models and data

- [DBNet detector](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/model.py): `model/model.py`
- [CNN feature extractor](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/model.py): `model/model.py`
- [Transformer head](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/model.py): `model/model.py`
- [Character set](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/data/charset.json): `data/charset.json`
- [Model checkpoints](https://github.com/ioannisdev/image_to_text_-ocr-/tree/main/model_pt): `model_pt`
- [OCR training dataset](https://github.com/ioannisdev/image_to_text_-ocr-/blob/main/model/OCR_dataset.py): `model/OCR_dataset.py`

### Other components

- **Camera operator**

## Connections

- Camera operator → Camera frames: provides input (evidence: `README.md`)
- Camera frames → Inference demo: supplies frames (evidence: `model/proto_inference.py`)
- Inference demo → Pipeline loader: loads pipeline (evidence: `model/proto_inference.py`)
- Inference demo → DBNet detector: configures model (evidence: `model/proto_inference.py`)
- Inference demo → CNN feature extractor: configures model (evidence: `model/proto_inference.py`)
- Inference demo → Transformer head: configures model (evidence: `model/proto_inference.py`)
- Inference demo → Character set: reads character set (evidence: `model/proto_inference.py`)
- Pipeline loader → Model checkpoints: loads weights (evidence: `model/ocr_pipeline.py`)
- Pipeline loader → Character set: reads character set (evidence: `model/ocr_pipeline.py`)
- Pipeline loader → Image preparation: creates pipeline (evidence: `model/ocr_pipeline.py`)
- Image preparation → Text detection: prepares image (evidence: `model/ocr_pipeline.py`)
- Text detection → DBNet detector: predicts regions (evidence: `model/ocr_pipeline.py`)
- Text detection → Box postprocessing: decodes probability map (evidence: `model/ocr_pipeline.py`)
- Box postprocessing → Word crops: yields word boxes (evidence: `model/ocr_pipeline.py`)
- Word crops → Word recognition: prepares word images (evidence: `model/ocr_pipeline.py`)
- Word recognition → CNN feature extractor: extracts features (evidence: `model/ocr_pipeline.py`)
- Word recognition → Transformer head: predicts characters (evidence: `model/ocr_pipeline.py`)
- Word recognition → Character set: decodes characters (evidence: `model/ocr_pipeline.py`)
- Reading order → OCR result: assembles lines (evidence: `model/ocr_pipeline.py`)
- Inference demo → Reading order: requests OCR result (evidence: `model/proto_inference.py`)
- OCR result → Annotated preview: returns word boxes (evidence: `model/proto_inference.py`)
- Annotated preview → Camera operator: shows preview (evidence: `README.md`)
