# anisharyal09/lipi-snap architecture

> Architecture diagram of the GitHub repository anisharyal09/lipi-snap, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anisharyal09/lipi-snap
- Repository: https://github.com/anisharyal09/lipi-snap

## Overview

Lipi Snap is a Ranjana-script OCR application: users provide a word image and receive a Devanagari transcription, with optional IAST transliteration and English translation. The main runtime is the Streamlit word-level CRNN/CTC app; separate tools prepare synthetic training examples, and training/evaluation scripts support the model lifecycle. The tree and excerpts also document an older character-level CharCNN branch. Some app internals and dataset wiring are described only in the README, so uncertain implementation links are omitted.

Main entry points: [`app_word_crnn.py`](https://github.com/anisharyal09/lipi-snap/blob/main/app_word_crnn.py) (Streamlit app), [`tools/generate_word_images.py`](https://github.com/anisharyal09/lipi-snap/blob/main/tools/generate_word_images.py) (Synthetic image generation), [`model/train_crnn.py`](https://github.com/anisharyal09/lipi-snap/blob/main/model/train_crnn.py) (CRNN training), [`model`](https://github.com/anisharyal09/lipi-snap/tree/main/model) (Model checkpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Word Recognition"]
  node_wordapp["Streamlit app<br/>[app_word_crnn.py]"]
  node_preprocess["Image preprocessing<br/>[app_word_crnn.py]"]
  node_devanagari["Devanagari text<br/>[app_word_crnn.py]"]
  node_iast["IAST transliteration<br/>[app_word_crnn.py]"]
  node_translation["English translation<br/>[app_word_crnn.py]"]
  node_result["OCR results and metrics<br/>[app_word_crnn.py]"]
end

subgraph group_model["CRNN Model"]
  node_wordmodel["CRNN inference<br/>[app_word_crnn.py]"]
  node_ctc["CTC decoding<br/>[app_word_crnn.py]"]
  node_train["CRNN training<br/>[train_crnn.py]"]
  node_checkpoint["Model checkpoint"]
end

subgraph group_data["Data and Evaluation"]
  node_eval["Model evaluation"]
  node_words["Word lists<br/>[nepali_words.txt]"]
  node_testwords["Unseen test words<br/>[new_test_words.txt]"]
  node_cleaner["Word cleaning"]
  node_cleanwords["Clean test words"]
  node_generator["Synthetic image generation"]
  node_font["Ranjana font"]
  node_trainset["Training and test images"]
end

subgraph group_legacy["Character Archive"]
  node_charapp["Character-level app<br/>[app_char_cnn.py]"]
  node_charinfer["CharCNN inference<br/>[inference.py]"]
  node_chartrain["CharCNN training<br/>[train.py]"]
  node_charmaps["Character mappings"]
end

node_user(("Image user"))
node_indic["Indic transliteration"]
node_google["Google Translate"]

node_user -->|"uploads image"| node_wordapp
node_wordapp -->|"preprocesses"| node_preprocess
node_wordapp -->|"predicts word"| node_wordmodel
node_preprocess -->|"provides image"| node_wordmodel
node_wordmodel -->|"emits frame scores"| node_ctc
node_ctc -->|"decodes text"| node_devanagari
node_wordapp -->|"requests transliteration"| node_iast
node_iast -.->|"transliterates with"| node_indic
node_devanagari -->|"supplies text"| node_translation
node_wordapp -->|"requests translation"| node_translation
node_translation -.->|"translates via"| node_google
node_wordapp -->|"renders output"| node_result
node_devanagari -->|"provides transcription"| node_result
node_iast -->|"provides transliteration"| node_result
node_translation -->|"provides translation"| node_result
node_train -->|"reads samples"| node_trainset
node_train -->|"saves weights"| node_checkpoint
node_checkpoint -->|"loads weights"| node_wordapp
node_eval -->|"reads test samples"| node_trainset
node_eval -->|"loads weights"| node_checkpoint
node_testwords -->|"cleans and splits"| node_cleaner
node_cleaner -->|"writes words"| node_cleanwords
node_cleanwords -->|"provides labels"| node_generator
node_words -.->|"supplies word labels"| node_train
node_generator -->|"renders with"| node_font
node_generator -->|"writes image dataset"| node_trainset
node_user -.->|"uploads character image"| node_charapp
node_charapp -.->|"classifies character"| node_charinfer
node_charinfer -.->|"uses mappings"| node_charmaps
node_chartrain -.->|"uses class labels"| node_charmaps

click node_wordapp "https://github.com/anisharyal09/lipi-snap/blob/main/app_word_crnn.py"
click node_preprocess "https://github.com/anisharyal09/lipi-snap/blob/main/app_word_crnn.py"
click node_wordmodel "https://github.com/anisharyal09/lipi-snap/blob/main/app_word_crnn.py"
click node_ctc "https://github.com/anisharyal09/lipi-snap/blob/main/app_word_crnn.py"
click node_devanagari "https://github.com/anisharyal09/lipi-snap/blob/main/app_word_crnn.py"
click node_iast "https://github.com/anisharyal09/lipi-snap/blob/main/app_word_crnn.py"
click node_translation "https://github.com/anisharyal09/lipi-snap/blob/main/app_word_crnn.py"
click node_result "https://github.com/anisharyal09/lipi-snap/blob/main/app_word_crnn.py"
click node_train "https://github.com/anisharyal09/lipi-snap/blob/main/model/train_crnn.py"
click node_checkpoint "https://github.com/anisharyal09/lipi-snap/tree/main/model"
click node_eval "https://github.com/anisharyal09/lipi-snap/blob/main/model/evaluation_script.py"
click node_words "https://github.com/anisharyal09/lipi-snap/blob/main/data/nepali_words.txt"
click node_testwords "https://github.com/anisharyal09/lipi-snap/blob/main/data/new_test_words.txt"
click node_cleaner "https://github.com/anisharyal09/lipi-snap/blob/main/tools/clean_split_words.py"
click node_cleanwords "https://github.com/anisharyal09/lipi-snap/blob/main/data/new_test_words_clean.txt"
click node_generator "https://github.com/anisharyal09/lipi-snap/blob/main/tools/generate_word_images.py"
click node_font "https://github.com/anisharyal09/lipi-snap/blob/main/font/NithyaRanjanaDU-Regular.otf"
click node_trainset "https://github.com/anisharyal09/lipi-snap/tree/main/data"
click node_charapp "https://github.com/anisharyal09/lipi-snap/blob/main/CharCNN/app_char_cnn.py"
click node_charinfer "https://github.com/anisharyal09/lipi-snap/blob/main/CharCNN/model/inference.py"
click node_chartrain "https://github.com/anisharyal09/lipi-snap/blob/main/CharCNN/model/train.py"
click node_charmaps "https://github.com/anisharyal09/lipi-snap/tree/main/CharCNN/mapping"

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_wordapp,node_preprocess,node_devanagari,node_iast,node_translation,node_result,node_user toneBlue
class node_wordmodel,node_ctc,node_train,node_checkpoint toneAmber
class node_eval,node_words,node_testwords,node_cleaner,node_cleanwords,node_generator,node_font,node_trainset toneMint
class node_charapp,node_charinfer,node_chartrain,node_charmaps toneRose
class node_indic,node_google toneIndigo
```

## Components

### Word Recognition

- [Streamlit app](https://github.com/anisharyal09/lipi-snap/blob/main/app_word_crnn.py): `app_word_crnn.py`
- [Image preprocessing](https://github.com/anisharyal09/lipi-snap/blob/main/app_word_crnn.py): `app_word_crnn.py`
- [Devanagari text](https://github.com/anisharyal09/lipi-snap/blob/main/app_word_crnn.py): `app_word_crnn.py`
- [IAST transliteration](https://github.com/anisharyal09/lipi-snap/blob/main/app_word_crnn.py): `app_word_crnn.py`
- [English translation](https://github.com/anisharyal09/lipi-snap/blob/main/app_word_crnn.py): `app_word_crnn.py`
- [OCR results and metrics](https://github.com/anisharyal09/lipi-snap/blob/main/app_word_crnn.py): `app_word_crnn.py`

### CRNN Model

- [CRNN inference](https://github.com/anisharyal09/lipi-snap/blob/main/app_word_crnn.py): `app_word_crnn.py`
- [CTC decoding](https://github.com/anisharyal09/lipi-snap/blob/main/app_word_crnn.py): `app_word_crnn.py`
- [CRNN training](https://github.com/anisharyal09/lipi-snap/blob/main/model/train_crnn.py): `model/train_crnn.py`
- [Model checkpoint](https://github.com/anisharyal09/lipi-snap/tree/main/model): `model`

### Data and Evaluation

- [Model evaluation](https://github.com/anisharyal09/lipi-snap/blob/main/model/evaluation_script.py): `model/evaluation_script.py`
- [Word lists](https://github.com/anisharyal09/lipi-snap/blob/main/data/nepali_words.txt): `data/nepali_words.txt`
- [Unseen test words](https://github.com/anisharyal09/lipi-snap/blob/main/data/new_test_words.txt): `data/new_test_words.txt`
- [Word cleaning](https://github.com/anisharyal09/lipi-snap/blob/main/tools/clean_split_words.py): `tools/clean_split_words.py`
- [Clean test words](https://github.com/anisharyal09/lipi-snap/blob/main/data/new_test_words_clean.txt): `data/new_test_words_clean.txt`
- [Synthetic image generation](https://github.com/anisharyal09/lipi-snap/blob/main/tools/generate_word_images.py): `tools/generate_word_images.py`
- [Ranjana font](https://github.com/anisharyal09/lipi-snap/blob/main/font/NithyaRanjanaDU-Regular.otf): `font/NithyaRanjanaDU-Regular.otf`
- [Training and test images](https://github.com/anisharyal09/lipi-snap/tree/main/data): `data`

### Character Archive

- [Character-level app](https://github.com/anisharyal09/lipi-snap/blob/main/CharCNN/app_char_cnn.py): `CharCNN/app_char_cnn.py`
- [CharCNN inference](https://github.com/anisharyal09/lipi-snap/blob/main/CharCNN/model/inference.py): `CharCNN/model/inference.py`
- [CharCNN training](https://github.com/anisharyal09/lipi-snap/blob/main/CharCNN/model/train.py): `CharCNN/model/train.py`
- [Character mappings](https://github.com/anisharyal09/lipi-snap/tree/main/CharCNN/mapping): `CharCNN/mapping`

### Other components

- **Image user**
- **Indic transliteration**
- **Google Translate**

## Connections

- Image user → Streamlit app: uploads image
- Streamlit app → Image preprocessing: preprocesses
- Streamlit app → CRNN inference: predicts word
- Image preprocessing → CRNN inference: provides image
- CRNN inference → CTC decoding: emits frame scores
- CTC decoding → Devanagari text: decodes text
- Streamlit app → IAST transliteration: requests transliteration
- IAST transliteration → Indic transliteration: transliterates with
- Devanagari text → English translation: supplies text
- Streamlit app → English translation: requests translation
- English translation → Google Translate: translates via
- Streamlit app → OCR results and metrics: renders output
- Devanagari text → OCR results and metrics: provides transcription
- IAST transliteration → OCR results and metrics: provides transliteration
- English translation → OCR results and metrics: provides translation
- CRNN training → Training and test images: reads samples
- CRNN training → Model checkpoint: saves weights
- Model checkpoint → Streamlit app: loads weights
- Model evaluation → Training and test images: reads test samples
- Model evaluation → Model checkpoint: loads weights
- Unseen test words → Word cleaning: cleans and splits
- Word cleaning → Clean test words: writes words
- Clean test words → Synthetic image generation: provides labels
- Word lists → CRNN training: supplies word labels
- Synthetic image generation → Ranjana font: renders with
- Synthetic image generation → Training and test images: writes image dataset
- Image user → Character-level app: uploads character image
- Character-level app → CharCNN inference: classifies character
- CharCNN inference → Character mappings: uses mappings
- CharCNN training → Character mappings: uses class labels
