Skip to content

Repository files navigation

Lipika — Indic Font Recognizer

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

PyPI Python License HF Model 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.

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

pip install lipika
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.

Free hosted API (no model download)

The demo Space doubles as a free REST-ish API for prototypes and low-volume apps:

pip install gradio_client
from gradio_client import Client, handle_file

client = Client("anilpai/lipika-demo")
_, result = client.predict(handle_file("hindi_text.png"), api_name="/recognize")
print(result["predictions"][0]["family"])

For production traffic, run the model yourself (pip install lipika) — CPU inference takes a few seconds per image. Runnable versions of both paths live in examples/.

Run the demo locally

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.

Why Loopdesk built this

Loopdesk 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 or start a HF discussion.

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 for the full build log (12 phases, v1 → v2.4).

License

Code: Apache-2.0. Model weights: Apache-2.0 (model card). 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.

About

Lipika (लिपिका) — Indic font recognizer: image of text → font family, weight, script + WOFF2 URL. 563 families, 13 scripts.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages