Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix crash when selecting language model #38

Merged
merged 1 commit into from
Jul 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 26 additions & 18 deletions PPOCRLabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3117,7 +3117,8 @@ def autolcm(self):
self.actions.AutoRec.setEnabled(True)

def modelChoose(self):
print(self.comboBox.currentText())
current_text = self.comboBox.currentText()
print(current_text)
lg_idx = {
"Chinese & English": "ch",
"English": "en",
Expand All @@ -3126,23 +3127,30 @@ def modelChoose(self):
"Korean": "korean",
"Japanese": "japan",
}
del self.ocr
self.ocr = PaddleOCR(
use_pdserving=False,
use_angle_cls=True,
det=True,
cls=True,
use_gpu=False,
lang=lg_idx[self.comboBox.currentText()],
)
del self.table_ocr
self.table_ocr = PPStructure(
use_pdserving=False,
use_gpu=False,
lang=lg_idx[self.comboBox.currentText()],
layout=False,
show_log=False,
)
if current_text in lg_idx:
choose_lang = lg_idx[current_text]
if hasattr(self, "ocr"):
del self.ocr
self.ocr = PaddleOCR(
use_pdserving=False,
use_angle_cls=True,
det=True,
cls=True,
use_gpu=False,
lang=choose_lang,
)
if choose_lang in ["ch", "en"]:
if hasattr(self, "table_ocr"):
del self.table_ocr
self.table_ocr = PPStructure(
use_pdserving=False,
use_gpu=False,
lang=choose_lang,
layout=False,
show_log=False,
)
else:
print("Invalid language selection")
self.dialog.close()

def cancel(self):
Expand Down