CTC converter update

This commit is contained in:
Baek JeongHun 2019-04-24 15:33:17 +00:00
parent 017df17d56
commit 1db0bfc0e8
1 changed files with 4 additions and 4 deletions

View File

@ -6,15 +6,15 @@ class CTCLabelConverter(object):
def __init__(self, character):
# character (str): set of the possible characters.
list_token = ['[blank]'] # dummy '[blank]' token for CTCLoss (index 0)
list_character = list(character)
self.character = list_token + list_character
dict_character = list(character)
self.dict = {}
for i, char in enumerate(list_character):
for i, char in enumerate(dict_character):
# NOTE: 0 is reserved for 'blank' token required by CTCLoss
self.dict[char] = i + 1
self.character = ['[blank]'] + dict_character # dummy '[blank]' token for CTCLoss (index 0)
def encode(self, text):
"""convert text-label into text-index.
input: