Skip to content

Commit

Permalink
reverse output for rtl languages has bug. (#10418)
Browse files Browse the repository at this point in the history
  • Loading branch information
masoudMZB authored Jan 3, 2024
1 parent b1f6c21 commit a916057
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions ppocr/postprocess/rec_postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from bidi.algorithm import get_display
import numpy as np
import paddle
from paddle.nn import functional as F
Expand Down Expand Up @@ -49,20 +50,7 @@ def __init__(self, character_dict_path=None, use_space_char=False):
self.character = dict_character

def pred_reverse(self, pred):
pred_re = []
c_current = ''
for c in pred:
if not bool(re.search('[a-zA-Z0-9 :*./%+-]', c)):
if c_current != '':
pred_re.append(c_current)
pred_re.append(c)
c_current = ''
else:
c_current += c
if c_current != '':
pred_re.append(c_current)

return ''.join(pred_re[::-1])
return get_display(pred)

def add_special_char(self, dict_character):
return dict_character
Expand Down

0 comments on commit a916057

Please sign in to comment.