import gradio as gr from PIL import Image from datetime import datetime import pytz from ocr_engine import extract_weight def process_image(image): if image is None: return "No image provided", "", None try: weight = extract_weight(image) ist = pytz.timezone('Asia/Kolkata') timestamp = datetime.now(ist).strftime("%Y-%m-%d %H:%M:%S IST") return weight, timestamp, image except Exception as e: return f"Error: {str(e)}", "", None with gr.Blocks(css=".gr-button {background-color: #2e7d32 !important; color: white !important;}") as demo: gr.Markdown("""
AI-powered OCR tool to detect weights (kg or grams) from digital balance display images.
Developed by Shalu | Powered by Hugging Face OCR 🚀
""")