|
@@ -14,6 +14,8 @@ from paddleocr import PaddleOCR
|
|
from PIL import Image
|
|
from PIL import Image
|
|
import numpy as np
|
|
import numpy as np
|
|
|
|
|
|
|
|
+os.environ["OMP_NUM_THREADS"] = "1"
|
|
|
|
+os.environ["MKL_NUM_THREADS"] = "1"
|
|
|
|
|
|
app = Flask(__name__)
|
|
app = Flask(__name__)
|
|
app.config.from_object(
|
|
app.config.from_object(
|
|
@@ -21,6 +23,8 @@ app.config.from_object(
|
|
)
|
|
)
|
|
cache = Cache(app, config={"CACHE_TYPE": "SimpleCache"})
|
|
cache = Cache(app, config={"CACHE_TYPE": "SimpleCache"})
|
|
|
|
|
|
|
|
+ocr = PaddleOCR(use_angle_cls=True, lang='en') # Adjust language if needed
|
|
|
|
+
|
|
app.config['SESSION_COOKIE_SECURE'] = True # Only send cookie over HTTPS
|
|
app.config['SESSION_COOKIE_SECURE'] = True # Only send cookie over HTTPS
|
|
app.config['SESSION_COOKIE_HTTPONLY'] = True # Prevent JavaScript access
|
|
app.config['SESSION_COOKIE_HTTPONLY'] = True # Prevent JavaScript access
|
|
app.config['SESSION_COOKIE_SAMESITE'] = 'Lax' # Adjust for cross-site requests
|
|
app.config['SESSION_COOKIE_SAMESITE'] = 'Lax' # Adjust for cross-site requests
|
|
@@ -167,7 +171,6 @@ def OCRupload():
|
|
# Get the uploaded file
|
|
# Get the uploaded file
|
|
file = request.files['image']
|
|
file = request.files['image']
|
|
try:
|
|
try:
|
|
- ocr = PaddleOCR(use_angle_cls=True, lang='en') # Adjust language if needed
|
|
|
|
image = Image.open(file.stream)
|
|
image = Image.open(file.stream)
|
|
image_np = np.array(image)
|
|
image_np = np.array(image)
|
|
result = ocr.ocr(image_np)
|
|
result = ocr.ocr(image_np)
|