Spaces:
Runtime error
Runtime error
MedaSaiCharan
commited on
Commit
•
d229e0d
1
Parent(s):
c15de2c
changes in app.py
Browse files- app.py +8 -3
- packages.txt +1 -0
- requirements.txt +1 -2
app.py
CHANGED
@@ -7,9 +7,14 @@ import PIL
|
|
7 |
from PIL import Image, ImageOps
|
8 |
import cv2
|
9 |
import pytesseract
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
13 |
|
14 |
# Loading different models
|
15 |
mnist_cnn_model = load_model('./models/mnist_cnn_model.h5')
|
@@ -38,7 +43,7 @@ def pre_process(image, model_name):
|
|
38 |
result = np.argmax(pred)
|
39 |
return str(result)
|
40 |
elif model_name == "OCR - preferred":
|
41 |
-
pred =
|
42 |
return pred
|
43 |
else:
|
44 |
return "Invalid model selection"
|
|
|
7 |
from PIL import Image, ImageOps
|
8 |
import cv2
|
9 |
import pytesseract
|
10 |
+
import os
|
11 |
+
langs = []
|
12 |
|
13 |
+
choices = os.popen('tesseract --list-langs').read().split('\n')[1:-1]
|
14 |
+
def run(image, lang=None):
|
15 |
+
result = pytesseract.image_to_string(
|
16 |
+
image, lang=None if lang == [] else lang)
|
17 |
+
return result
|
18 |
|
19 |
# Loading different models
|
20 |
mnist_cnn_model = load_model('./models/mnist_cnn_model.h5')
|
|
|
43 |
result = np.argmax(pred)
|
44 |
return str(result)
|
45 |
elif model_name == "OCR - preferred":
|
46 |
+
pred = run(image)
|
47 |
return pred
|
48 |
else:
|
49 |
return "Invalid model selection"
|
packages.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
tesseract-ocr-all
|
requirements.txt
CHANGED
@@ -4,5 +4,4 @@ pandas
|
|
4 |
numpy
|
5 |
Pillow
|
6 |
opencv-python
|
7 |
-
pytesseract
|
8 |
-
tesseract
|
|
|
4 |
numpy
|
5 |
Pillow
|
6 |
opencv-python
|
7 |
+
pytesseract
|
|