import pytesseract from PIL import Image import re def extract_weight_from_image(image): """Extract weight as a decimal number (e.g., 53.76) from the image.""" try: text = pytesseract.image_to_string(image) match = re.search(r"\d+.\d{2}", text) if match: return match.group() return "No weight found" except Exception as e: return f"Error: {str(e)}"