Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions trdg/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down Expand Up @@ -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:
Expand All @@ -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__":
Expand Down