# factodeeplearning/meta-dan architecture

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

- Interactive diagram: https://gitdiagram.com/factodeeplearning/meta-dan
- Repository: https://github.com/factodeeplearning/meta-dan

## Overview

Meta-DAN is a PyTorch handwritten-text-recognition research package supporting page-level and line-level models. Users format a dataset or supply an image, choose a model through the CLI, then train, evaluate, or predict; training can use synthetic samples and pretrained weights, and recognition output can include attention visualizations. The graph preserves the README’s model families and dataset-formatting capability. Some subsystem links are documented only by README or the SOURCE INDEX; unsampled implementation details are not asserted.

Main entry points: [`dar/text_recognition/run.py`](https://github.com/factodeeplearning/meta-dan/blob/main/dar/text_recognition/run.py) (Model runner), [`dar/generic/training_manager.py`](https://github.com/factodeeplearning/meta-dan/blob/main/dar/generic/training_manager.py) (Training engine), [`dar/text_recognition/ocr_dataset_manager.py`](https://github.com/factodeeplearning/meta-dan/blob/main/dar/text_recognition/ocr_dataset_manager.py) (OCR datasets), [`dar/cli.py`](https://github.com/factodeeplearning/meta-dan/blob/main/dar/cli.py) (CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and formatting"]
  node_cli["CLI<br/>[cli.py]"]
  node_dataset_formats["Dataset formatters"]
  node_run["Model runner<br/>[run.py]"]
end

subgraph group_data["Datasets and synthesis"]
  node_datasets["OCR datasets"]
  node_generic_datasets["Dataset loading<br/>[dataset_manager.py]"]
  node_synthetic["Synthetic generation"]
  node_synthetic_content["Synthetic content"]
end

subgraph group_recognition["Recognition models"]
  node_tokenizer["Tokenizer<br/>[tokenizer.py]"]
  node_line_ctc["Line CTC"]
  node_dan["DAN"]
  node_faster_dan["Faster DAN"]
  node_w_dan["W-DAN"]
  node_mt_dan["MT-DAN"]
  node_meta_dan["Meta-DAN"]
end

subgraph group_runtime["Training and evaluation"]
  node_ocr_manager["OCR manager<br/>[ocr_manager.py]"]
  node_training["Training engine"]
  node_metrics["Metrics<br/>[metric_manager.py]"]
  node_scheduler["Schedulers<br/>[scheduler.py]"]
  node_weights["Pretrained weights"]
  node_predictions["Predictions"]
end

node_user(("User"))
node_weight_host["Hugging Face"]

node_user -->|"invokes"| node_cli
node_cli -->|"dispatches model"| node_run
node_cli -->|"dispatches format"| node_dataset_formats
node_dataset_formats -->|"formats dataset for"| node_datasets
node_run -->|"selects model"| node_line_ctc
node_run -->|"selects model"| node_dan
node_run -->|"selects model"| node_faster_dan
node_run -->|"selects model"| node_w_dan
node_run -->|"selects model"| node_mt_dan
node_run -->|"selects model"| node_meta_dan
node_run -->|"creates manager"| node_ocr_manager
node_ocr_manager -->|"extends"| node_training
node_training -->|"uses dataset"| node_datasets
node_datasets -->|"extends dataset"| node_generic_datasets
node_datasets -->|"requests samples"| node_synthetic
node_synthetic -->|"uses generators"| node_synthetic_content
node_training -->|"uses metrics"| node_metrics
node_training -->|"uses schedulers"| node_scheduler
node_training -->|"downloads weights"| node_weights
node_weights -.->|"retrieves checkpoints"| node_weight_host
node_ocr_manager -->|"writes results"| node_predictions
node_user -->|"requests prediction"| node_predictions

click node_cli "https://github.com/factodeeplearning/meta-dan/blob/main/dar/cli.py"
click node_dataset_formats "https://github.com/factodeeplearning/meta-dan/tree/main/dar/dataset_format"
click node_run "https://github.com/factodeeplearning/meta-dan/blob/main/dar/text_recognition/run.py"
click node_datasets "https://github.com/factodeeplearning/meta-dan/blob/main/dar/text_recognition/ocr_dataset_manager.py"
click node_generic_datasets "https://github.com/factodeeplearning/meta-dan/blob/main/dar/generic/dataset_manager.py"
click node_synthetic "https://github.com/factodeeplearning/meta-dan/blob/main/dar/text_recognition/synthetic/synthetic_manager.py"
click node_synthetic_content "https://github.com/factodeeplearning/meta-dan/tree/main/dar/text_recognition/synthetic"
click node_tokenizer "https://github.com/factodeeplearning/meta-dan/blob/main/dar/text_recognition/tokenizer.py"
click node_line_ctc "https://github.com/factodeeplearning/meta-dan/tree/main/dar/text_recognition/line/ctc"
click node_dan "https://github.com/factodeeplearning/meta-dan/tree/main/dar/text_recognition/document/dan"
click node_faster_dan "https://github.com/factodeeplearning/meta-dan/tree/main/dar/text_recognition/document/faster_dan"
click node_w_dan "https://github.com/factodeeplearning/meta-dan/tree/main/dar/text_recognition/document/w_dan"
click node_mt_dan "https://github.com/factodeeplearning/meta-dan/tree/main/dar/text_recognition/document/mt_dan"
click node_meta_dan "https://github.com/factodeeplearning/meta-dan/tree/main/dar/text_recognition/document/meta_dan"
click node_ocr_manager "https://github.com/factodeeplearning/meta-dan/blob/main/dar/text_recognition/ocr_manager.py"
click node_training "https://github.com/factodeeplearning/meta-dan/blob/main/dar/generic/training_manager.py"
click node_metrics "https://github.com/factodeeplearning/meta-dan/blob/main/dar/generic/metric_manager.py"
click node_scheduler "https://github.com/factodeeplearning/meta-dan/blob/main/dar/generic/scheduler.py"
click node_weights "https://github.com/factodeeplearning/meta-dan/blob/main/dar/text_recognition/download_pretrained_weights.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_cli,node_dataset_formats,node_run,node_user toneBlue
class node_datasets,node_generic_datasets,node_synthetic,node_synthetic_content toneAmber
class node_tokenizer,node_line_ctc,node_dan,node_faster_dan,node_w_dan,node_mt_dan,node_meta_dan toneMint
class node_ocr_manager,node_training,node_metrics,node_scheduler,node_weights,node_predictions toneRose
class node_weight_host toneIndigo
```

## Components

### Entry and formatting

- [CLI](https://github.com/factodeeplearning/meta-dan/blob/main/dar/cli.py): `dar/cli.py`
- [Dataset formatters](https://github.com/factodeeplearning/meta-dan/tree/main/dar/dataset_format): `dar/dataset_format`
- [Model runner](https://github.com/factodeeplearning/meta-dan/blob/main/dar/text_recognition/run.py): `dar/text_recognition/run.py`

### Datasets and synthesis

- [OCR datasets](https://github.com/factodeeplearning/meta-dan/blob/main/dar/text_recognition/ocr_dataset_manager.py): `dar/text_recognition/ocr_dataset_manager.py`
- [Dataset loading](https://github.com/factodeeplearning/meta-dan/blob/main/dar/generic/dataset_manager.py): `dar/generic/dataset_manager.py`
- [Synthetic generation](https://github.com/factodeeplearning/meta-dan/blob/main/dar/text_recognition/synthetic/synthetic_manager.py): `dar/text_recognition/synthetic/synthetic_manager.py`
- [Synthetic content](https://github.com/factodeeplearning/meta-dan/tree/main/dar/text_recognition/synthetic): `dar/text_recognition/synthetic`

### Recognition models

- [Tokenizer](https://github.com/factodeeplearning/meta-dan/blob/main/dar/text_recognition/tokenizer.py): `dar/text_recognition/tokenizer.py`
- [Line CTC](https://github.com/factodeeplearning/meta-dan/tree/main/dar/text_recognition/line/ctc): `dar/text_recognition/line/ctc`
- [DAN](https://github.com/factodeeplearning/meta-dan/tree/main/dar/text_recognition/document/dan): `dar/text_recognition/document/dan`
- [Faster DAN](https://github.com/factodeeplearning/meta-dan/tree/main/dar/text_recognition/document/faster_dan): `dar/text_recognition/document/faster_dan`
- [W-DAN](https://github.com/factodeeplearning/meta-dan/tree/main/dar/text_recognition/document/w_dan): `dar/text_recognition/document/w_dan`
- [MT-DAN](https://github.com/factodeeplearning/meta-dan/tree/main/dar/text_recognition/document/mt_dan): `dar/text_recognition/document/mt_dan`
- [Meta-DAN](https://github.com/factodeeplearning/meta-dan/tree/main/dar/text_recognition/document/meta_dan): `dar/text_recognition/document/meta_dan`

### Training and evaluation

- [OCR manager](https://github.com/factodeeplearning/meta-dan/blob/main/dar/text_recognition/ocr_manager.py): `dar/text_recognition/ocr_manager.py`
- [Training engine](https://github.com/factodeeplearning/meta-dan/blob/main/dar/generic/training_manager.py): `dar/generic/training_manager.py`
- [Metrics](https://github.com/factodeeplearning/meta-dan/blob/main/dar/generic/metric_manager.py): `dar/generic/metric_manager.py`
- [Schedulers](https://github.com/factodeeplearning/meta-dan/blob/main/dar/generic/scheduler.py): `dar/generic/scheduler.py`
- [Pretrained weights](https://github.com/factodeeplearning/meta-dan/blob/main/dar/text_recognition/download_pretrained_weights.py): `dar/text_recognition/download_pretrained_weights.py`
- **Predictions**

### Other components

- **User**
- **Hugging Face**

## Connections

- User → CLI: invokes
- CLI → Model runner: dispatches model (evidence: `dar/cli.py`)
- CLI → Dataset formatters: dispatches format (evidence: `dar/cli.py`)
- Dataset formatters → OCR datasets: formats dataset for
- Model runner → Line CTC: selects model (evidence: `dar/text_recognition/run.py`)
- Model runner → DAN: selects model (evidence: `dar/text_recognition/run.py`)
- Model runner → Faster DAN: selects model (evidence: `dar/text_recognition/run.py`)
- Model runner → W-DAN: selects model (evidence: `dar/text_recognition/run.py`)
- Model runner → MT-DAN: selects model (evidence: `dar/text_recognition/run.py`)
- Model runner → Meta-DAN: selects model (evidence: `dar/text_recognition/run.py`)
- Model runner → OCR manager: creates manager (evidence: `dar/text_recognition/run.py`)
- OCR manager → Training engine: extends (evidence: `dar/text_recognition/ocr_manager.py`)
- Training engine → OCR datasets: uses dataset (evidence: `dar/text_recognition/ocr_manager.py`)
- OCR datasets → Dataset loading: extends dataset (evidence: `dar/text_recognition/ocr_dataset_manager.py`)
- OCR datasets → Synthetic generation: requests samples (evidence: `dar/text_recognition/ocr_dataset_manager.py`)
- Synthetic generation → Synthetic content: uses generators (evidence: `dar/text_recognition/synthetic/synthetic_manager.py`)
- Training engine → Metrics: uses metrics (evidence: `dar/generic/training_manager.py`)
- Training engine → Schedulers: uses schedulers (evidence: `dar/generic/training_manager.py`)
- Training engine → Pretrained weights: downloads weights (evidence: `dar/generic/training_manager.py`)
- Pretrained weights → Hugging Face: retrieves checkpoints
- OCR manager → Predictions: writes results (evidence: `dar/text_recognition/ocr_manager.py`)
- User → Predictions: requests prediction
