Update app.py
Browse files
app.py
CHANGED
|
@@ -7,11 +7,10 @@ import sys
|
|
| 7 |
import io
|
| 8 |
from ultralytics import YOLO
|
| 9 |
import time
|
| 10 |
-
import
|
| 11 |
|
| 12 |
# Set the default encoding to utf-8
|
| 13 |
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
| 14 |
-
reader = easyocr.Reader(['en'])
|
| 15 |
|
| 16 |
app = Flask(__name__)
|
| 17 |
|
|
@@ -81,13 +80,9 @@ def textis():
|
|
| 81 |
|
| 82 |
# Convert to RGB format
|
| 83 |
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
| 84 |
-
|
| 85 |
|
| 86 |
-
|
| 87 |
-
extracted_text = " ".join([text[1] for text in result]) # Concatenate the detected text
|
| 88 |
-
istext = bool(extracted_text.strip())
|
| 89 |
-
|
| 90 |
-
# Return True if any text was detected, otherwise False
|
| 91 |
istext=bool(extracted_text.strip())
|
| 92 |
|
| 93 |
# Resize the image to the expected input size of the model (e.g., 225x225)
|
|
|
|
| 7 |
import io
|
| 8 |
from ultralytics import YOLO
|
| 9 |
import time
|
| 10 |
+
import pytesseract
|
| 11 |
|
| 12 |
# Set the default encoding to utf-8
|
| 13 |
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
|
|
|
| 14 |
|
| 15 |
app = Flask(__name__)
|
| 16 |
|
|
|
|
| 80 |
|
| 81 |
# Convert to RGB format
|
| 82 |
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
| 83 |
+
extracted_text = pytesseract.image_to_string(gray_image)
|
| 84 |
|
| 85 |
+
# Return True if any text was detected, otherwise False
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
istext=bool(extracted_text.strip())
|
| 87 |
|
| 88 |
# Resize the image to the expected input size of the model (e.g., 225x225)
|