MCPcopy Create free account
hub / github.com/PaddlePaddle/Serving / encode

Method encode

python/paddle_serving_app/reader/ocr_reader.py:60–79  ·  view source on GitHub ↗

convert text-label into text-index. input: text: text labels of each image. [batch_size] output: text: concatenated text index for CTCLoss. [sum(text_lengths)] = [text_index_0 + text_index_1 + ... + text_index_(n - 1)] length:

(self, text)

Source from the content-addressed store, hash-verified

58 self.character = dict_character
59
60 def encode(self, text):
61 """convert text-label into text-index.
62 input:
63 text: text labels of each image. [batch_size]
64
65 output:
66 text: concatenated text index for CTCLoss.
67 [sum(text_lengths)] = [text_index_0 + text_index_1 + ... + text_index_(n - 1)]
68 length: length of each text. [batch_size]
69 """
70 if self.character_type == "en":
71 text = text.lower()
72
73 text_list = []
74 for char in text:
75 if char not in self.dict:
76 continue
77 text_list.append(self.dict[char])
78 text = np.array(text_list)
79 return text
80
81 def decode(self, text_index, is_remove_duplicate=False):
82 """ convert text-index into text-label. """

Callers 15

get_keyMethod · 0.45
check_keyMethod · 0.45
do_POSTMethod · 0.45
printable_textFunction · 0.45
mask2outMethod · 0.45
preprocessMethod · 0.45
preprocessMethod · 0.45
preprocessMethod · 0.45
preprocessMethod · 0.45
preprocessMethod · 0.45
preprocessMethod · 0.45
printable_textFunction · 0.45

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected