File size: 645 Bytes
b4959be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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)