Skip to content

Commit

Permalink
reset latex ocr (#14047)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyubo0722 authored Oct 18, 2024
1 parent cb36de1 commit ee1aa57
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ppocr/modeling/heads/rec_latexocr_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,15 +948,15 @@ def generate_export(
b, t = start_tokens.shape

self.net.eval()
out_tmp = start_tokens
out = start_tokens
mask = kwargs.pop("mask", None)

if mask is None:
mask = paddle.full_like(out_tmp, True, dtype=paddle.bool)
mask = paddle.full_like(out, True, dtype=paddle.bool)

i_idx = paddle.full([], 0)
while i_idx < paddle.to_tensor(seq_len):
x = out_tmp[:, -self.max_seq_len :]
x = out[:, -self.max_seq_len :]
paddle.jit.api.set_dynamic_shape(x, [-1, -1])
mask = mask[:, -self.max_seq_len :]
paddle.jit.api.set_dynamic_shape(mask, [-1, -1])
Expand All @@ -969,7 +969,7 @@ def generate_export(
probs = F.softmax(filtered_logits / temperature, axis=-1)

sample = paddle.multinomial(probs, 1)
out = paddle.concat((out_tmp, sample), axis=-1)
out = paddle.concat((out, sample), axis=-1)

pad_mask = paddle.full(shape=[mask.shape[0], 1], fill_value=1, dtype="bool")
mask = paddle.concat((mask, pad_mask), axis=1)
Expand Down

0 comments on commit ee1aa57

Please sign in to comment.