Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write the labels to separate files #326

Open
DesBw opened this issue Nov 8, 2023 · 0 comments
Open

Write the labels to separate files #326

DesBw opened this issue Nov 8, 2023 · 0 comments

Comments

@DesBw
Copy link

DesBw commented Nov 8, 2023

I was trying to use the labels as ground-truth texts in tesseract.
Currently, trdg writes the labels into a single lable.txt file.
I understand that the part of the script that writes them to single file is the following.

if args.name_format == 2:
      # Create file with filename-to-label connections
      with open(
          os.path.join(args.output_dir, "labels.txt"), "w", encoding="utf8"
      ) as f:
          for i in range(string_count):
              file_name = str(i) + "." + args.extension
              label = strings[i]
              if args.space_width == 0:
                  label = label.replace(" ", "")
              f.write("{} {}\n".format(file_name, label))

Can someone with sufficient knowledge of python can help me to modify it so that the labels will be written as separate files?

What I want is:

0.gt.txt
1.gt.txt
Each of those files would contain their respective labels inside.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant