MCPcopy Create free account
hub / github.com/buaacxf/VIPTR / __init__

Method __init__

utils.py:8–17  ·  view source on GitHub ↗
(self, character)

Source from the content-addressed store, hash-verified

6 """ Convert between text-label and text-index """
7
8 def __init__(self, character):
9 # character (str): set of the possible characters.
10 dict_character = list(character)
11
12 self.dict = {}
13 for i, char in enumerate(dict_character):
14 # NOTE: 0 is reserved for 'CTCblank' token required by CTCLoss
15 self.dict[char] = i + 1
16
17 self.character = ['[CTCblank]'] + dict_character # dummy '[CTCblank]' token for CTCLoss (index 0)
18
19 def encode(self, text, batch_max_length=25):
20 """convert text-label into text-index.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected