mirror of
https://github.com/PaddlePaddle/PaddleOCR.git
synced 2025-06-03 21:53:39 +08:00
reverse output for rtl languages has bug. (#10418)
This commit is contained in:
parent
b1f6c210b3
commit
a916057501
@ -12,6 +12,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
from bidi.algorithm import get_display
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import paddle
|
import paddle
|
||||||
from paddle.nn import functional as F
|
from paddle.nn import functional as F
|
||||||
@ -49,20 +50,7 @@ class BaseRecLabelDecode(object):
|
|||||||
self.character = dict_character
|
self.character = dict_character
|
||||||
|
|
||||||
def pred_reverse(self, pred):
|
def pred_reverse(self, pred):
|
||||||
pred_re = []
|
return get_display(pred)
|
||||||
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])
|
|
||||||
|
|
||||||
def add_special_char(self, dict_character):
|
def add_special_char(self, dict_character):
|
||||||
return dict_character
|
return dict_character
|
||||||
|
Loading…
x
Reference in New Issue
Block a user