kalpesh77 commited on
Commit
1da9954
·
verified ·
1 Parent(s): 90f309f

Upload ocr/engine.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. ocr/engine.py +29 -0
ocr/engine.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ दृष्टी स्तर: प्रतिमेतून मराठी मजकूर वाचणे
3
+ """
4
+ import pytesseract
5
+ from PIL import Image
6
+
7
+ class MarathiOCR:
8
+ """वैदिक मराठी OCR इंजिन"""
9
+
10
+ def __init__(self, tesseract_path='/usr/bin/tesseract'):
11
+ pytesseract.pytesseract.tesseract_cmd = tesseract_path
12
+
13
+ def read_image(self, image_path):
14
+ """👁️ दृष्टी: प्रतिमेतून मराठी मजकूर वाचणे"""
15
+ img = Image.open(image_path)
16
+ return pytesseract.image_to_string(img, lang='mar')
17
+
18
+ def process(self, image_path):
19
+ """संपूर्ण पाइपलाइन: OCR + बोलीभाषा + सांकेतिक भाषा"""
20
+ from .decomposer import generate_stable_outputs
21
+
22
+ text = self.read_image(image_path)
23
+ boli, symbolic = generate_stable_outputs(text)
24
+
25
+ return {
26
+ 'raw': text,
27
+ 'boli': boli,
28
+ 'symbolic': symbolic
29
+ }