From c55a6f980302e5c161ccd9de8ff86b9f4dd2cb0f Mon Sep 17 00:00:00 2001 From: liuhongen1234567 <2998388548@qq.com> Date: Thu, 20 Mar 2025 08:44:23 +0000 Subject: [PATCH 1/2] fix onnx in latexocr --- ppocr/modeling/heads/rec_latexocr_head.py | 16 ++-------------- requirements.txt | 2 +- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/ppocr/modeling/heads/rec_latexocr_head.py b/ppocr/modeling/heads/rec_latexocr_head.py index 1b01d9d6dc6..edd27f3bf74 100644 --- a/ppocr/modeling/heads/rec_latexocr_head.py +++ b/ppocr/modeling/heads/rec_latexocr_head.py @@ -907,14 +907,7 @@ def generate( x = out[:, -self.max_seq_len :] mask = mask[:, -self.max_seq_len :] logits = self.net(x, mask=mask, **kwargs)[:, -1, :] - if filter_logits_fn in {top_k, top_p}: - filtered_logits = filter_logits_fn(logits, thres=filter_thres) - - probs = F.softmax(filtered_logits / temperature, axis=-1) - else: - raise NotImplementedError("The filter_logits_fn is not supported ") - - sample = paddle.multinomial(probs, 1) + sample = paddle.argmax(logits, axis=1).reshape([-1, 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) @@ -966,12 +959,7 @@ def generate_export( logits = self.net(x, mask=mask, context=context, seq_len=i_idx, **kwargs)[ :, -1, : ] - if filter_logits_fn in {top_k, top_p}: - filtered_logits = filter_logits_fn(logits, thres=filter_thres) - - probs = F.softmax(filtered_logits / temperature, axis=-1) - - sample = paddle.multinomial(probs, 1) + sample = paddle.argmax(logits, axis=1).reshape([-1, 1]) out = paddle.concat((out, sample), axis=-1) pad_mask = paddle.full(shape=[mask.shape[0], 1], fill_value=1, dtype="bool") diff --git a/requirements.txt b/requirements.txt index 7fc903cb270..9cdc043208b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,5 +13,5 @@ pyyaml requests albumentations # to be compatible with albumentations -albucore +albucore==0.0.16 packaging From 928b24704bdc69b2b41f625a333e65bf05220d23 Mon Sep 17 00:00:00 2001 From: liuhongen1234567 <2998388548@qq.com> Date: Thu, 20 Mar 2025 13:16:21 +0000 Subject: [PATCH 2/2] recover require --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 9cdc043208b..7fc903cb270 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,5 +13,5 @@ pyyaml requests albumentations # to be compatible with albumentations -albucore==0.0.16 +albucore packaging