From a6cddef7617f0a91fa5d0ead1840143e1fcb023e Mon Sep 17 00:00:00 2001 From: Karl Date: Fri, 18 Jul 2025 11:51:01 +0100 Subject: [PATCH] remove paddleocr --- app.py | 39 +------------------------------------ dockerfile | 6 ------ requirements.txt | Bin 326 -> 304 bytes templates/add_account.html | 22 +-------------------- 4 files changed, 2 insertions(+), 65 deletions(-) diff --git a/app.py b/app.py index 690cff4..f493755 100644 --- a/app.py +++ b/app.py @@ -17,13 +17,6 @@ from lib.reqs import (get_urls, get_user_accounts, add_user_account, delete_user_account, get_stream_names) from config import DevelopmentConfig, ProductionConfig -try: - from paddleocr import PaddleOCR - from PIL import Image - import numpy as np - OCR_AVAILABLE = True -except ImportError: - OCR_AVAILABLE = False os.environ["OMP_NUM_THREADS"] = "1" os.environ["MKL_NUM_THREADS"] = "1" @@ -52,10 +45,7 @@ except redis.exceptions.ConnectionError as e: cache = Cache(app, config=cache_config) -if app.config.get("OCR_ENABLED") and OCR_AVAILABLE: - ocr = PaddleOCR(use_angle_cls=True, lang='en') -else: - app.config["OCR_ENABLED"] = False +app.config["OCR_ENABLED"] = False app.config["SESSION_COOKIE_SECURE"] = not app.config["DEBUG"] app.config['SESSION_COOKIE_HTTPONLY'] = True @@ -213,7 +203,6 @@ def home() -> str: accounts=len(all_accounts), current_month_accounts=filter_accounts_next_30_days(all_accounts), expired_accounts=filter_accounts_expired(all_accounts), - ocr_enabled=app.config.get("OCR_ENABLED"), ) return render_template("index.html") @@ -300,7 +289,6 @@ def add_account() -> Union[Response, str]: return render_template( "add_account.html", - ocr_enabled=app.config.get("OCR_ENABLED"), text_input_enabled=app.config.get("TEXT_INPUT_ENABLED"), shared_text=shared_text ) @@ -345,31 +333,6 @@ def stream_names() -> Union[Response, str]: base_url = app.config["BASE_URL"] return jsonify(get_stream_names(base_url, session["auth_credentials"])) -if app.config.get("OCR_ENABLED"): - @app.route('/OCRupload', methods=['POST']) - def ocr_upload() -> Union[Response, str, Tuple[Response, int]]: - """Handles image uploads for OCR processing.""" - if 'image' not in request.files: - return jsonify({"error": "No image file found"}), 400 - file = request.files['image'] - try: - image = Image.open(file.stream) - image_np = np.array(image) - result = ocr.ocr(image_np) - extracted_text = [line[1][0] for line in result[0]] - # Basic validation - if len(extracted_text) >= 4: - return render_template( - "add_account.html", - username=extracted_text[2], - password=extracted_text[3], - ocr_enabled=True, - text_input_enabled=app.config.get("TEXT_INPUT_ENABLED") - ) - else: - return jsonify({"error": "Could not extract required fields from image"}), 400 - except Exception as e: - return jsonify({"error": str(e)}), 500 if __name__ == "__main__": app.run( diff --git a/dockerfile b/dockerfile index 62c5712..a58f7a0 100644 --- a/dockerfile +++ b/dockerfile @@ -9,12 +9,6 @@ RUN pip install --no-cache-dir --prefix=/install -r requirements.txt # Final stage FROM python:3.11-slim-bookworm AS final -RUN apt-get update && apt-get install -y --no-install-recommends \ - libgomp1 \ - libgl1 \ - libglib2.0-0 \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* WORKDIR /app diff --git a/requirements.txt b/requirements.txt index 92ed44897b05f1ca591ee419f4a9ce9672fcfff8..288b289ae7304ccb886f001a03065aa3b430f80f 100644 GIT binary patch delta 9 QcmX@cw1H_t$;7Tb02B@cRsaA1 delta 27 hcmdnMbc|_2iC_UkB0~xg<}jo( @@ -50,20 +49,6 @@ Add Account - {% if ocr_enabled %} -
-

Load Details Via OCR

-
-
- - -
- -
- {% endif %} {% if text_input_enabled %}

Load Details Via Text

@@ -82,11 +67,6 @@ document.getElementById("loadingSpinner").style.display = "inline-block"; document.getElementById("buttonText").textContent = "Working..."; } - function showLoadingOCR() { - document.getElementById("ocrButton").disabled = true; - document.getElementById("ocrLoadingSpinner").style.display = "inline-block"; - document.getElementById("ocrButtonText").textContent = "Processing..."; - } document.addEventListener("DOMContentLoaded", function() { var streamInput = document.getElementById("stream");