Skip to main content

OCR extraction and text grouping for product/nutrition label images

Project description

Lightweight, stateless Python library for extracting structured data from product packaging labels using OCR and LLM-based parsing.

PyPI version Python 3.8+ License: MIT

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tejas_label_ocr-0.1.2.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tejas_label_ocr-0.1.2-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file tejas_label_ocr-0.1.2.tar.gz.

File metadata

  • Download URL: tejas_label_ocr-0.1.2.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.9

File hashes

Hashes for tejas_label_ocr-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c3b506ca2726958c428dede6c13a59d7978743e6bb65275faf59f7b3953c345f
MD5 a21309e88eb9143e29f54350c400d9dc
BLAKE2b-256 55983a561fbad1e83396981062e6d3b025d11f8fef3e0d0215394122e0d0a599

See more details on using hashes here.

File details

Details for the file tejas_label_ocr-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for tejas_label_ocr-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 12fee311cc7c7b2a82884118f1de2bdc5843197f0cc95580979a6304d618b030
MD5 69068fa07f34045ab43f5b2d4b28f07c
BLAKE2b-256 7cd95360a9a3d40eaf3346ba4b3b77cd2691141ee760eb59d0c8497cbd0b16f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page