From dad3ad48c2a8d273a044ffb364f3d7f5f1d7adc6 Mon Sep 17 00:00:00 2001 From: tuxiaohui001 Date: Mon, 27 Feb 2023 16:01:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E9=98=BF=E6=8B=89=E4=BC=AF=E8=AF=AD?= =?UTF-8?q?=E7=B3=BB=E6=A0=87=E7=AD=BE=E4=B8=8D=E6=AD=A3=E7=A1=AE=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E8=BF=9B=E8=A1=8C=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trdg/run.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/trdg/run.py b/trdg/run.py index 65edd1291c..8c19e741dd 100755 --- a/trdg/run.py +++ b/trdg/run.py @@ -419,8 +419,9 @@ def main(): if args.language == "ar": from arabic_reshaper import ArabicReshaper from bidi.algorithm import get_display - arabic_reshaper = ArabicReshaper() + # 修改阿拉伯语系文本标签进行修改 + strings_ar = [get_display(x) for x in strings] strings = [ " ".join( [get_display(arabic_reshaper.reshape(w)) for w in s.split(" ")[::-1]] @@ -475,9 +476,12 @@ def main(): ): pass p.terminate() - + # 修改输出格式,直接返回paddleocr样式 if args.name_format == 2: # Create file with filename-to-label connections + # 对阿拉伯语系标签进行修改 + if args.language == "ar": + strings = strings_ar with open( os.path.join(args.output_dir, "labels.txt"), "w", encoding="utf8" ) as f: @@ -486,7 +490,7 @@ def main(): label = strings[i] if args.space_width == 0: label = label.replace(" ", "") - f.write("{} {}\n".format(file_name, label)) + f.write("{0}/images/{1}\t{2}\n".format(args.output_dir, file_name, label)) if __name__ == "__main__":