Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Label OCR (tejas-label-ocr)

PyPI Version Python Version


✨ 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.

About

PyPI tool to extract information from product front and nutrition labels.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages