Add: [TW] cnocr model for tw

This commit is contained in:
LmeSzinc 2021-11-14 12:39:17 +08:00
parent 8e0a10974b
commit 93cc5e7bd7
4 changed files with 7242 additions and 0 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -30,6 +30,16 @@ OCR_MODEL = {
'cnocr': AlOcr(model_name='densenet-lite-gru', model_epoch=39, root='./bin/cnocr_models/cnocr', name='cnocr'),
'jp': AlOcr(model_name='densenet-lite-gru', model_epoch=125, root='./bin/cnocr_models/jp', name='jp'),
# Folder: ./bin/cnocr_models/tw
# Size: 8.43MB
# Model: densenet-lite-gru
# Epoch: 63
# Validation accuracy: 99.24%
# Font: Various, 6 kinds
# Charset: Numbers, Upper english characters, Chinese traditional characters
# _num_classes: 5322
'tw': AlOcr(model_name='densenet-lite-gru', model_epoch=63, root='./bin/cnocr_models/tw', name='tw'),
}
@ -50,6 +60,7 @@ class Ocr:
self.letter = letter
self.threshold = threshold
self.alphabet = alphabet
self.lang = lang
self.cnocr = OCR_MODEL[lang]
def pre_process(self, image):
@ -74,6 +85,10 @@ class Ocr:
"""
result = ''.join(result)
if self.lang == 'tw':
# There no letter `艦` in training dataset
result = result.replace('', '')
return result
def ocr(self, image, direct_ocr=False):
@ -104,6 +119,7 @@ class Digit(Ocr):
Do OCR on a digit, such as `45`.
Method ocr() returns int, or a list of int.
"""
def __init__(self, buttons, lang='azur_lane', letter=(255, 255, 255), threshold=128, alphabet='0123456789',
name=None):
super().__init__(buttons, lang=lang, letter=letter, threshold=threshold, alphabet=alphabet, name=name)