Metadata-Version: 2.4
Name: lipika
Version: 2.4.0
Summary: Lipika (लिपिका) — Indic font recognizer: image of text → font family, weight, script + hosted WOFF2 URL. 563 families, 13 scripts.
Author-email: Anil Pai <anilbpai@gmail.com>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/Loopdesk-AI/lipika
Project-URL: Model, https://huggingface.co/loopdesk-ai/lipika
Project-URL: Demo, https://huggingface.co/spaces/anilpai/lipika-demo
Keywords: font-recognition,indic,typography,devanagari,tamil,bengali,telugu,kannada,malayalam,ocr,fonts
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Scientific/Engineering :: Image Recognition
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pillow>=10.0
Requires-Dist: numpy>=1.26
Requires-Dist: pandas>=2.1
Requires-Dist: torch>=2.9
Requires-Dist: timm>=1.0
Requires-Dist: safetensors>=0.4
Requires-Dist: huggingface_hub>=0.20
Provides-Extra: data
Requires-Dist: requests>=2.31; extra == "data"
Requires-Dist: fonttools>=4.50; extra == "data"
Requires-Dist: tqdm>=4.66; extra == "data"
Provides-Extra: train
Requires-Dist: torchvision>=0.24; extra == "train"
Requires-Dist: requests>=2.31; extra == "train"
Requires-Dist: fonttools>=4.50; extra == "train"
Requires-Dist: tqdm>=4.66; extra == "train"
Provides-Extra: demo
Requires-Dist: gradio>=5.0; extra == "demo"
Provides-Extra: hf
Dynamic: license-file

# Lipika — Indic Font Recognizer

**लिपिका** · Identify the font in an image of Indic-script text.

Upload a crop of text in any of 13 Indic scripts and Lipika returns the font
family, weight, italic flag, and a hosted WOFF2 URL you can use immediately —
plus visually-nearest alternatives from a retrieval index.

- 🤗 **Model**: [loopdesk-ai/lipika](https://huggingface.co/loopdesk-ai/lipika)
- 🎨 **Demo**: [anilpai/lipika-demo](https://huggingface.co/spaces/anilpai/lipika-demo)

## What it does

| | |
|---|---|
| **Families** | 563 (Google Fonts, Fontsource, SMC, CDAC/SALRC, legacy freeware) |
| **Scripts** | Devanagari, Bengali, Tamil, Telugu, Kannada, Malayalam, Gujarati, Gurmukhi, Odia, Ol Chiki, Meetei Mayek, Arabic (Urdu), Latin |
| **Outputs** | family (top-k), weight (100–900), italic, script, WOFF2 URL |
| **Backbone** | ConvNeXt-V2-Tiny (28M params), multi-head + ArcFace, patch-voting inference |
| **Accuracy** | 0.86 val top-1 · 0.90 real-photo R@1 · 0.88 retrieval R@1 |

## Quick start

```bash
pip install lipika
```

```python
from PIL import Image
from fontrecog.infer.predictor import Predictor  # package installs as `lipika`, imports as `fontrecog`

p = Predictor.from_pretrained("loopdesk-ai/lipika")
result = p.predict(Image.open("hindi_text.png"))

top = result["predictions"][0]
print(result["script"], top["family"], top["confidence"], top["woff2_url"])
# devanagari Tiro Devanagari Hindi 0.30 https://cdn.jsdelivr.net/...
```

The result dict also contains `grouped_predictions` (per-family, weights
merged), `retrieval` (visually nearest families with cosine similarity), and
calibrated `uncertain` / `match_quality` flags for open-set inputs.

## Run the demo locally

```bash
pip install "lipika[demo]"
python -m fontrecog.demo --repo loopdesk-ai/lipika   # Gradio on :7861
```

## How it was built

Everything is synthetic-first: training crops are rendered on the fly from
font files (HarfBuzz shaping via a Pillow/raqm stack), augmented with real-
photo-style degradations, and mixed with a small real-crop set. The corpus
pipeline, training loop (Modal.com L4 GPUs), retrieval index build, and
calibration are all in this repo:

```
src/fontrecog/
  data/        corpus manifest, font fetching, WOFF2 self-hosting
  dataset/     synthetic rendering, augmentation, val shard freezing
  train/       multi-head loop (family + script + weight + italic, ArcFace)
  index/       prototype retrieval index build + open-set calibration
  infer/       Predictor (patch voting, TTA, hedging), HF export
  eval/        frozen-shard + real-photo eval harnesses
  demo.py      Gradio app
```

See [`plan.md`](https://github.com/Loopdesk-AI/lipika/blob/main/plan.md) for the full build log (12 phases, v1 → v2.4).

## License

Code: [Apache-2.0](https://github.com/Loopdesk-AI/lipika/blob/main/LICENSE). Model weights: Apache-2.0
([model card](https://huggingface.co/loopdesk-ai/lipika)). Fonts referenced by
the recognizer remain under their own licenses (OFL and similar); the model
repo hosts only redistributable font files.

---

Developed & maintained by [Loopdesk](https://huggingface.co/loopdesk-ai).
