Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import torch
|
|
4 |
import numpy as np
|
5 |
import cv2
|
6 |
from PIL import Image
|
7 |
-
import pytesseract
|
8 |
from sentence_transformers import SentenceTransformer, util
|
9 |
import io
|
10 |
|
@@ -27,7 +27,7 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
27 |
|
28 |
# Move model to the appropriate device (CPU or CUDA)
|
29 |
model.to(device)
|
30 |
-
|
31 |
# Load a smaller version of Sentence-BERT model
|
32 |
model1 = SentenceTransformer('all-MiniLM-L6-v2')
|
33 |
|
@@ -56,7 +56,7 @@ def extract_text_from_image(image):
|
|
56 |
# Convert PIL image to RGB format
|
57 |
image = image.convert('RGB')
|
58 |
# Use pytesseract to extract text from the image
|
59 |
-
text =
|
60 |
return text.strip()
|
61 |
|
62 |
def evaluate_answer(image):
|
|
|
4 |
import numpy as np
|
5 |
import cv2
|
6 |
from PIL import Image
|
7 |
+
import pytesseract as tess
|
8 |
from sentence_transformers import SentenceTransformer, util
|
9 |
import io
|
10 |
|
|
|
27 |
|
28 |
# Move model to the appropriate device (CPU or CUDA)
|
29 |
model.to(device)
|
30 |
+
tess.pytesseract.tesseract_cmd = r"/app/tesseract.exe"
|
31 |
# Load a smaller version of Sentence-BERT model
|
32 |
model1 = SentenceTransformer('all-MiniLM-L6-v2')
|
33 |
|
|
|
56 |
# Convert PIL image to RGB format
|
57 |
image = image.convert('RGB')
|
58 |
# Use pytesseract to extract text from the image
|
59 |
+
text = tess.image_to_string(image)
|
60 |
return text.strip()
|
61 |
|
62 |
def evaluate_answer(image):
|