Lightweight, stateless Python library for extracting structured data from product packaging labels using OCR and LLM-based parsing.
—
Features
Stateless & In-Memory: Processes raw image bytes—no disk I/O, ideal for serverless (FastAPI/Flask).
OCR + LLM Powered: Uses EasyOCR for text extraction and Mistral AI (mistral-small-latest) for structured parsing.
Noise Filtering: Automatically cleans low-confidence OCR text and groups spatial blocks (rows/columns/proximity).
Flexible Auth: Pass api_key directly or via MISTRAL_API_KEY environment variable.
Structured JSON Output: Extracts brand, product name, ingredients, nutrition facts, allergens, and more.
—
Installation
pip install tejas-label-ocr
—
Usage
Front Label Processing
from label_ocr import process_front_label
with open("product_label.jpg", "rb") as f:
image_bytes = f.read()
result = process_front_label(image_bytes, api_key="your-mistral-api-key")
print(result)
# Output: {"brand": "Nestlé", "product_name": "Organic Oats", "claims": ["Gluten-Free", "Non-GMO"], ...}
Nutrition Label Processing
from label_ocr import process_nutrition_label
with open("nutrition_panel.jpg", "rb") as f:
image_bytes = f.read()
result = process_nutrition_label(image_bytes, api_key="your-mistral-api-key")
print(result)
# Output: {"serving_size": "30g", "nutrients": [{"name": "Calories", "value": 120, "unit": "kcal", "%RDA": 6}], ...}
— Notes —–
Requires a Mistral AI API key (sign up at Mistral AI).
For best results, use high-resolution images of labels with clear text.
Metadata
Release files for tejas-label-ocr 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tejas_label_ocr-0.1.5.tar.gz | 8.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tejas_label_ocr-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.4 kB
Release files / tejas_label_ocr-0.1.5.tar.gz
| Download URL | tejas_label_ocr-0.1.5.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b84444efea7ecc5656dce40b98e89ea516f3d2d1862975a1b5d7c1b8192e34f
|
|
BLAKE2b-256 checksum How to use checksums |
1c121fa9a034a96583a93bc5af8fbef6ee9af71d3458d939890eee7d0cc7199f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|
Release files / tejas_label_ocr-0.1.5-py3-none-any.whl
| Download URL | tejas_label_ocr-0.1.5-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
35a7bc509398c1d08c1c99a856e43e2c0217dba8b822f5bb79b4c24cda871987
|
|
BLAKE2b-256 checksum How to use checksums |
4cc38be100b0ac08e487e36ddc00780bf277eab3569f3c6a84b50bd9711cfa2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|