mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: correct PaddleOCR language codes for model download and OCR
PaddleOCR uses its own language codes (ch, japan, korean, latin) not ISO codes (zh, ja, ko, de, fr, es). The download script and ocr.py now map API language codes to PaddleOCR codes correctly. German, French, and Spanish all use the "latin" script model.
This commit is contained in:
@@ -23,7 +23,9 @@ REMBG_MODELS = [
|
||||
"birefnet-general",
|
||||
]
|
||||
|
||||
PADDLEOCR_LANGUAGES = ["en", "de", "fr", "es", "zh", "ja", "ko"]
|
||||
# PaddleOCR language codes (not ISO). German/French/Spanish use "latin" model.
|
||||
# Valid keys: ch, en, korean, japan, chinese_cht, ta, te, ka, latin, arabic, cyrillic, devanagari
|
||||
PADDLEOCR_LANGUAGES = ["en", "ch", "japan", "korean", "latin"]
|
||||
|
||||
|
||||
def download_rembg_models():
|
||||
|
||||
@@ -36,8 +36,12 @@ def run_paddleocr(input_path, language):
|
||||
from paddleocr import PaddleOCR
|
||||
from gpu import gpu_available
|
||||
|
||||
# Map API language codes to PaddleOCR codes
|
||||
paddle_lang_map = {"en": "en", "de": "latin", "fr": "latin", "es": "latin", "zh": "ch", "ja": "japan", "ko": "korean"}
|
||||
paddle_lang = paddle_lang_map.get(language, "en")
|
||||
|
||||
emit_progress(20, "Loading")
|
||||
ocr = PaddleOCR(lang=language, use_gpu=gpu_available())
|
||||
ocr = PaddleOCR(lang=paddle_lang, use_gpu=gpu_available())
|
||||
emit_progress(30, "Scanning")
|
||||
result = ocr.ocr(input_path)
|
||||
emit_progress(70, "Extracting text")
|
||||
|
||||
Reference in New Issue
Block a user