JaydeepR commited on
Commit
ba94498
·
verified ·
1 Parent(s): ab73d7d

Create text_extraction_model.py

Browse files
Files changed (1) hide show
  1. text_extraction_model.py +19 -0
text_extraction_model.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import easyocr
2
+ import numpy as np
3
+
4
+ # Load the EasyOCR reader
5
+ reader = easyocr.Reader(['en'], gpu=False)
6
+
7
+ def extract_text(image):
8
+ # Convert the image to an array for OCR
9
+ image_np = np.array(image)
10
+
11
+ # Perform OCR on the image
12
+ result = reader.readtext(image_np)
13
+
14
+ # Extract text from the OCR result
15
+ extracted_text = []
16
+ for (bbox, text, prob) in result:
17
+ extracted_text.append(text)
18
+
19
+ return extracted_text