Metadata-Version: 2.4
Name: lipika
Version: 2.4.1
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.

[![PyPI](https://img.shields.io/pypi/v/lipika?color=blue&label=pip%20install%20lipika)](https://pypi.org/project/lipika/)
[![Python](https://img.shields.io/pypi/pyversions/lipika)](https://pypi.org/project/lipika/)
[![License](https://img.shields.io/badge/license-Apache--2.0-green)](LICENSE)
[![HF Model](https://img.shields.io/badge/%F0%9F%A4%97%20Model-loopdesk--ai%2Flipika-orange)](https://huggingface.co/loopdesk-ai/lipika)
[![Demo](https://img.shields.io/badge/%F0%9F%A4%97%20Space-lipika--demo-yellow)](https://huggingface.co/spaces/anilpai/lipika-demo)

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.

- 📦 **PyPI**: [`pip install lipika`](https://pypi.org/project/lipika/)
- 🤗 **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
```

## Why this exists

India's internet has gone decisively Indic — ~98% of its 886M+ internet users consume
Indian-language content (IAMAI–Kantar 2024) — and its visual culture is the world's largest:
1,700–2,400 films a year in 20+ languages, 240M+ newspapers in daily circulation. Yet every
mainstream font identifier (WhatTheFont, Matcherator, Adobe Match Font) is trained on Latin
catalogs and fails outright on Devanagari, Tamil, or Bengali; academic prior art
(DeepFont) is Latin-only. Indic type is also genuinely harder: conjunct ligatures reshape
glyphs by context, sibling families are near-identical, and government/DTP workflows still
run on non-Unicode legacy encodings (Kruti Dev, DevLys) whose documents are unreadable
unless you first identify the font from pixels. Full story on the
[model card](https://huggingface.co/loopdesk-ai/lipika).

## Why Loopdesk built this

[Loopdesk](https://huggingface.co/loopdesk-ai) is an **agentic video editor — built from
India, for the world** — and one of the first editors to support practically every free
Indic font. Our pipeline analyses millions of video frames every second; when a frame
contains Indic text, the editor needs to know *which font that is* to load the matching
free font and keep the design consistent through edits. Nothing could answer that for
Indic scripts, so we built Lipika and open-sourced it.

## What you could build with it

- A **"WhatTheFont for Indic" browser extension** — right-click any image (movie poster,
  meme, news graphic) → family + instant WOFF2 preview; CPU inference takes seconds
- **Movie-poster / title-card typography analysis** at Indian-cinema scale
- **Font-aware OCR & archive digitization** — identify legacy families (Kruti Dev/DevLys)
  before OCR; the bundled `krutidev → Unicode` converter makes those bytes recoverable
- **Design & localization tooling** — match a screenshot to the nearest *free* font via
  retrieval embeddings
- **Brand/typography audits** and **document forensics** for Indic markets

**Want to build an Indic font *generator*?** We'd love to help — open a
[GitHub issue](https://github.com/Loopdesk-AI/lipika/issues) or start a
[HF discussion](https://huggingface.co/loopdesk-ai/lipika/discussions).

## 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).
