MCPcopy Create free account
hub / github.com/Topdu/OpenOCR / encode

Method encode

openrec/preprocess/dptr_label_encode.py:113–118  ·  view source on GitHub ↗
(self,
               labels: List[str],
               device: Optional[torch.device] = None)

Source from the content-addressed store, hash-verified

111 ]
112
113 def encode(self,
114 labels: List[str],
115 device: Optional[torch.device] = None) -> Tensor:
116 batch = [self.bos_id] + self._tok2ids(labels) + [self.eos_id]
117 return batch
118 # return pad_sequence(batch, batch_first=True, padding_value=self.pad_id)
119
120 def _filter(self, probs: Tensor, ids: Tensor) -> Tuple[Tensor, List[int]]:
121 ids = ids.tolist()

Callers 15

mainFunction · 0.45
createDatasetFunction · 0.45
mainFunction · 0.45
get_lmdb_sample_infoMethod · 0.45
get_wh_ratioMethod · 0.45
get_lmdb_sample_infoMethod · 0.45
get_wh_ratioMethod · 0.45
get_lmdb_sample_infoMethod · 0.45
get_wh_ratioMethod · 0.45

Calls 1

_tok2idsMethod · 0.80

Tested by 8

get_wh_ratioMethod · 0.36
get_lmdb_sample_infoMethod · 0.36
get_wh_ratioMethod · 0.36
get_lmdb_sample_infoMethod · 0.36
_preprocess_labelsMethod · 0.36
__getitem__Method · 0.36