Skip to content

Fix OCR language model switching - #264

Merged
GreatV merged 2 commits into
PFCCLab:mainfrom
YDLuo-1:codex/fix-model-language-switch
Aug 27, 2026
Merged

Fix OCR language model switching#264
GreatV merged 2 commits into
PFCCLab:mainfrom
YDLuo-1:codex/fix-model-language-switch

Conversation

@YDLuo-1

@YDLuo-1 YDLuo-1 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Problem

The language dialog passed both lang and fixed detection/recognition model names to PaddleOCR. PaddleOCR ignores lang when model names or directories are provided, so selecting another language did not actually switch the recognition model. The standalone TextRecognition instance used by re-recognition also remained on the old model.

Changes

  • map the six language choices to their PP-OCRv5 recognition models while keeping the existing mobile detection model
  • initialize the default recognition model consistently with --lang
  • rebuild both the full OCR pipeline and standalone recognizer when the selection changes
  • preserve the current selection when reopening the language dialog
  • keep custom model names/directories unchanged

Verification

  • python -m py_compile PPOCRLabel.py
  • mock regression check: switching from Chinese to English selects en_PP-OCRv5_mobile_rec for both PaddleOCR and TextRecognition, keeps PP-OCRv5_mobile_det, and restores English in the dialog
  • git diff --check

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes OCR language switching by ensuring the recognition model actually changes when the user selects a different language, and by keeping the standalone TextRecognition instance in sync with the main PaddleOCR pipeline.

Changes:

  • Introduces a language→recognition-model mapping for PP-OCRv5 recognition while keeping the existing detection model.
  • Initializes the recognition model selection consistently at startup (based on --lang) and rebuilds both OCR pipeline + standalone recognizer when the selection changes.
  • Restores the previously selected language when reopening the language dialog.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread PPOCRLabel.py Outdated
Comment thread PPOCRLabel.py

@GreatV GreatV left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@GreatV
GreatV merged commit b1b1291 into PFCCLab:main Aug 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants