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

Amharic #168

Open
wants to merge 5 commits into
base: amharic
Choose a base branch
from
Open
Show file tree
Hide file tree
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
20 changes: 8 additions & 12 deletions TextRecognitionDataGenerator/data_generator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import random

import uuid
from PIL import Image, ImageFilter

from computer_text_generator import ComputerTextGenerator
Expand Down Expand Up @@ -119,15 +119,11 @@ def generate(cls, index, text, font, out_dir, size, extension, skewing_angle, ra
#####################################
# Generate name for resulting image #
#####################################
if name_format == 0:
image_name = '{}_{}.{}'.format(text, str(index), extension)
elif name_format == 1:
image_name = '{}_{}.{}'.format(str(index), text, extension)
elif name_format == 2:
image_name = '{}.{}'.format(str(index),extension)
else:
print('{} is not a valid name format. Using default.'.format(name_format))
image_name = '{}_{}.{}'.format(text, str(index), extension)


image_name = '{}.{}'.format(str(uuid.uuid4()),extension)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this added to the PR by mistake? I can't really change the behavior of TRDG like that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, sorry, this was added by mistake, I was working on make TRDG available for amharic language and it printed blank images, so I made changes which involved adding a new font for amharic & removing the name factor as utf-8 based file names were saved as "", which happened to clash with my own configuration. i hope it didn't cause any harm.

file_poth = os.path.join(out_dir, image_name)
# Save the image
final_image.convert('RGB').save(os.path.join(out_dir, image_name))
with open('/content/bgg.txt', 'a',encoding="utf8") as the_file:
the_file.write(file_poth+" "+text+"⬤\n")

final_image.convert('RGB').save(file_poth)
Binary file not shown.
Binary file not shown.
Binary file not shown.