| import easyocr | |
| from typing import List | |
| class EasyOCRModel: | |
| def __init__(self): | |
| self.reader = easyocr.Reader(['en']) # Initialize with English; add languages if needed. | |
| def predict(self, image_path: str) -> List[str]: | |
| """ | |
| Perform OCR on the given image. | |
| Args: | |
| image_path (str): Path to the input image. | |
| Returns: | |
| List[str]: Extracted text from the image. | |
| """ | |
| return self.reader.readtext(image_path, detail=0) | |
| # Test the model locally | |
| if __name__ == "__main__": | |
| model = EasyOCRModel() | |
| result = model.predict("sample_image.jpg") | |
| print(result) | |