import pytesseract from PIL import Image # Set the Tesseract command path explicitly pytesseract.pytesseract.tesseract_cmd = "/usr/bin/tesseract" def extract_text(image): """Extracts text from the diagram using OCR.""" return pytesseract.image_to_string(Image.fromarray(image))