Giter VIP home page Giter VIP logo

textrecognitiondatagenerator's Issues

Find better german and spanish dictionaries

The dicts provided with the project for german and spanish are non-utf8. Unfortunately that means encoding errors may arise.

I will therefore try to replace the current dicts.

Generating Images similar to Oxford Synthetic Word Dataset

Hi,
I am trying to generate images containing single words similar to that in the Oxford Synthetic Word Dataset. The words will also contain symbols such as colon, percentage etc.
The process to create the Oxford dataset is described in the below image.
process

I am unsure how to generate such words along with symbols as I get such images below which are very much different from the ones in the Oxford dataset.
newsynth1
newsynth4

Images from Oxford dataset are given below,
synth1
synth2

run.py crashes (OSError: unknown file format) when generating dataset for new non- latin language

I added support for hebrew with some .fft fonts and a dictionary. The adjusted run.py and datagenerator.py files run and work till they crash. When I put run.py in a for loop it some times works flawlessly (and generates images) and sometimes crashes. Any thoughts?

text_rec_task) galmoore@Gals-MacBook-Pro:~/anaconda/envs/text_rec_task/TextRecognitionDataGenerator/TextRecognitionDataGenerator$ python run_script.py

Missing modules for handwritten text generation.

args count10

100%|██████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 56.40it/s]

Missing modules for handwritten text generation.

args count10

100%|█████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 102.17it/s]

Missing modules for handwritten text generation.

args count10

100%|██████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 67.58it/s]

Missing modules for handwritten text generation.

args count10

100%|█████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 108.27it/s]

Missing modules for handwritten text generation.

args count10

100%|██████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 70.82it/s]

Missing modules for handwritten text generation.

args count10

0%| | 0/10 [00:00<?, ?it/s]multiprocessing.pool.RemoteTraceback:

"""

Traceback (most recent call last):

File "/Users/galmoore/anaconda/envs/text_rec_task/lib/python3.6/multiprocessing/pool.py", line 119, in worker

result = (True, func(*args, **kwds))

File "/Users/galmoore/anaconda/envs/text_rec_task/TextRecognitionDataGenerator/TextRecognitionDataGenerator/data_generator.py", line 23, in generate_from_tuple

cls.generate(*t)

File "/Users/galmoore/anaconda/envs/text_rec_task/TextRecognitionDataGenerator/TextRecognitionDataGenerator/data_generator.py", line 42, in generate

image = computer_text_generator.generate(text, font, text_color, size, orientation, space_width, fit)

File "/Users/galmoore/anaconda/envs/text_rec_task/TextRecognitionDataGenerator/TextRecognitionDataGenerator/computer_text_generator.py", line 7, in generate

return _generate_horizontal_text(text, font, text_color, font_size, space_width, fit)

File "/Users/galmoore/anaconda/envs/text_rec_task/TextRecognitionDataGenerator/TextRecognitionDataGenerator/computer_text_generator.py", line 14, in _generate_horizontal_text

image_font = ImageFont.truetype(font=font, size=font_size)

File "/Users/galmoore/anaconda/envs/text_rec_task/lib/python3.6/site-packages/PIL/ImageFont.py", line 280, in truetype

return FreeTypeFont(font, size, index, encoding, layout_engine)

File "/Users/galmoore/anaconda/envs/text_rec_task/lib/python3.6/site-packages/PIL/ImageFont.py", line 145, in init

layout_engine=layout_engine)

OSError: unknown file format

"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "run.py", line 376, in

main()

File "run.py", line 364, in main

), total=args.count):

File "/Users/galmoore/anaconda/envs/text_rec_task/lib/python3.6/site-packages/tqdm/_tqdm.py", line 1005, in iter

for obj in iterable:

File "/Users/galmoore/anaconda/envs/text_rec_task/lib/python3.6/multiprocessing/pool.py", line 735, in next

raise value

OSError: unknown file format

Missing modules for handwritten text generation.

args count10

100%|██████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 70.12it/s]

Missing modules for handwritten text generation.

args count10

100%|██████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 44.38it/s]

Missing modules for handwritten text generation.

args count10

100%|██████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 37.21it/s]

Missing modules for handwritten text generation.

args count10

100%|██████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 53.60it/s]

chinese font problem

some chinese fonts can not generate good samples(for example ,some word could not be generated),do you have some suggests to solve the problem .thank you in advance

hello, i change the font and have a error

`The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Users/liufengnan/Desktop/TextRecognitionDataGenerator/TextRecognitionDataGenerator/run.py", line 392, in
main()
File "/Users/liufengnan/Desktop/TextRecognitionDataGenerator/TextRecognitionDataGenerator/run.py", line 309, in main
), total=args.count):
File "/usr/local/lib/python3.6/site-packages/tqdm/_tqdm.py", line 979, in iter
for obj in iterable:
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/multiprocessing/pool.py", line 735, in next
raise value
OSError: broken file
`

Support arabic and urdu text

Enhancement, but it would be interesting to add support for arabic and hindi scripts.

I think adding a new font folder and a new dict for both languages would work.

Text length

Can I generate texts with a fixed length size?

Fix dependencies versioning

OpenCV bumped their version from 3.2 to 3.4. Following this change, they removed the 3.2 version from PyPI. This means that right now, someone who clones the repo and tries to install the dependencies with pip install -r requirements it will fail.

Need to change how to name the file

Something embarrassing happened when I was generating the image T.T

FileNotFoundError: [Errno 2] No such file or directory: 'out/튃 귍 쓌 / 혦 찵 컒 뵶 명 똔 톨 눔_124.jpg'

This symbol ‘/’ should be '//'

run.py arguments in README.md

It would be very useful if all the command line arguments were mentioned in the readme file.
Obviously, it could be viewed in the run.py file. Still, a person who is cloning the repo for the first time may not know all the options available.

Thanks!

How to generate vertical images

for example we often read words and characters from left to right.
but in Chinese, we sometimes arrange characters from top to bottom.
So I just wonder can this code generate top to bottom configuration of Chinese sentences?

I got this error ,can anyone help me ?

1 .error:
/data/20180809/TextRecognitionDataGenerator-master/TextRecognitionDataGenerator# python run.py -i "texts/subtitle.txt" -c 100 -w 5 -e png -b 3
Missing modules for handwritten text generation.
31%|#####################################2 | 31/100 [00:00<00:01, 68.48it/s]multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/usr/lib/python3.4/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/data/20180809/TextRecognitionDataGenerator-master/TextRecognitionDataGenerator/data_generator.py", line 22, in generate_from_tuple
cls.generate(*t)
File "/data/20180809/TextRecognitionDataGenerator-master/TextRecognitionDataGenerator/data_generator.py", line 34, in generate
image = ComputerTextGenerator.generate(text, font, text_color)
File "/data/20180809/TextRecognitionDataGenerator-master/TextRecognitionDataGenerator/computer_text_generator.py", line 12, in generate
image_font = ImageFont.truetype(font=font, size=32)
File "/data/20180809/TextRecognitionDataGenerator-master/py3env/lib/python3.4/site-packages/PIL/ImageFont.py", line 261, in truetype
return FreeTypeFont(font, size, index, encoding, layout_engine)
File "/data/20180809/TextRecognitionDataGenerator-master/py3env/lib/python3.4/site-packages/PIL/ImageFont.py", line 144, in init
self.font = core.getfont(font, size, index, encoding, layout_engine=layout_engine)
OSError: unknown file format
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "run.py", line 290, in
main()
File "run.py", line 278, in main
), total=args.count):
File "/data/20180809/TextRecognitionDataGenerator-master/py3env/lib/python3.4/site-packages/tqdm/_tqdm.py", line 930, in iter
for obj in iterable:
File "/usr/lib/python3.4/multiprocessing/pool.py", line 689, in next
raise value
OSError: unknown file format

2.when i use my own background picture,i got the blurry picture,but i want a clear one.
image
image
why they got different width(ps:i use my own texts)
Looking forward to hear from you .
@Belval

Width and height of image

Why is the new_width being calculated in this line if it's not used anywhere else? Is it supposed to be used when resizing the image?

new_width = float(new_text_width + 10) * (float(height) / float(new_text_height + 10))

But the variable you are using when resizing is new_text_width.

image_on_background = background.resize((int(new_text_width), height), Image.ANTIALIAS)

ETA on numbers and symbols

Hi,

Great project, could you please let me know a rough time frame for a release with numbers and symbols included?

Best,
Vishal

TextDataRecognitionGenerator as a python module

The preferred usage had always been through the CLI. Unfortunately, this approach is not frictionless when used in a real machine learning pipeline that might include data augmentations.

The v1 candidate would be giving access to the data generators classes and have an easy to use interface that can be used as seamlessly as the CLI.

A package would be uploaded to pypi for ease of use.

Save generated text to file separately

How can I save generated text to the file alongside with the corresponding image? For example text 'foo' was generated and was put on some background and saved as foo.jpg. Can I save also text 'foo' to some file call it foo.txt where will be only text 'foo'?

osError: broken file

Traceback (most recent call last):
File "run.py", line 340, in
main()
File "run.py", line 328, in main
), total=args.count):
File "/data/env/anaconda3/lib/python3.6/site-packages/tqdm/_tqdm.py", line 931, in iter
for obj in iterable:
File "/data/env/anaconda3/lib/python3.6/multiprocessing/pool.py", line 735, in next
raise value
OSError: broken file
Exception ignored in: <bound method tqdm.del of 0%| | 21/500000 [00:00<6:24:25, 21.68it/s]>
Traceback (most recent call last):
File "/data/env/anaconda3/lib/python3.6/site-packages/tqdm/_tqdm.py", line 883, in del
File "/data/env/anaconda3/lib/python3.6/site-packages/tqdm/_tqdm.py", line 1088, in close
File "/data/env/anaconda3/lib/python3.6/site-packages/tqdm/_tqdm.py", line 439, in _decr_instances
File "/data/env/anaconda3/lib/python3.6/_weakrefset.py", line 109, in remove
KeyError: <weakref at 0x7f0af5879688; to 'tqdm' at 0x7f0bc8e1d0f0>

How to keep words in order

For example,I want to create a rule that some words must appear before some other words.Some words interval occur.So I guess when I use RNN network may have a better performance.

Create comprehensive test suite

As the number of feature grows I can barely check for regression bugs. Therefore a test suite should be made with a continuous integration like TravisCI.

Tighter cropping

Right now the images have quite a bit of unnecessary padding around the text, which reduces the usability of the generated dataset for specific tasks.

Instead, make text as big as possible and add a padding argument.

labels

hello,thanks firstly, is there a labels.txt in the code for the generated images?

background generator may cause error

if picture.size[0] < width:
picture = picture.resize([width, int(picture.size[1] * (width / picture.size[0]))],
#what if resized height is still smaller than needed height?
Image.ANTIALIAS)
elif picture.size[1] < height:
picture.thumbnail([int(picture.size[0] * (height / picture.size[1])), height], Image.ANTIALIAS)

Add argument font in run.py

Hi,
I used this repo to generate text with only one personal font.

I would like add a argument font in run.py, if a font is passed in param, it will be the only one used to generate pictures.

I will work in, I saw in readme you want an issue before a PR, so i open it 😊

I got this error, can anyone help me, please?

here is the error
python run.py -w 5 -f 64 -l am
0%| | 0/1000 [00:00<?, ?it/s]multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/home/test/Anaconda3/envs/py35/lib/python3.5/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/home/test/Documents/direse/scene/TextRecognitionDataGenerator/TextRecognitionDataGenerator/data_generator.py", line 22, in generate_from_tuple
cls.generate(*t)
File "/home/test/Documents/direse/scene/TextRecognitionDataGenerator/TextRecognitionDataGenerator/data_generator.py", line 36, in generate
image = ComputerTextGenerator.generate(text, font, text_color, size, orientation, space_width)
File "/home/test/Documents/direse/scene/TextRecognitionDataGenerator/TextRecognitionDataGenerator/computer_text_generator.py", line 9, in generate
return cls.__generate_horizontal_text(text, font, text_color, font_size, space_width)
File "/home/test/Documents/direse/scene/TextRecognitionDataGenerator/TextRecognitionDataGenerator/computer_text_generator.py", line 17, in __generate_horizontal_text
image_font = ImageFont.truetype(font=font, size=font_size)
File "/home/test/Anaconda3/envs/py35/lib/python3.5/site-packages/PIL/ImageFont.py", line 261, in truetype
return FreeTypeFont(font, size, index, encoding, layout_engine)
File "/home/test/Anaconda3/envs/py35/lib/python3.5/site-packages/PIL/ImageFont.py", line 144, in init
self.font = core.getfont(font, size, index, encoding, layout_engine=layout_engine)
OSError: unknown file format
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "run.py", line 342, in
main()
File "run.py", line 330, in main
), total=args.count):
File "/home/test/Anaconda3/envs/py35/lib/python3.5/site-packages/tqdm/_tqdm.py", line 930, in iter
for obj in iterable:
File "/home/test/Anaconda3/envs/py35/lib/python3.5/multiprocessing/pool.py", line 731, in next
raise value
OSError: unknown file format
Exception ignored in: <bound method tqdm.del of 0%| | 0/1000 [00:00<?, ?it/s]>
Traceback (most recent call last):
File "/home/test/Anaconda3/envs/py35/lib/python3.5/site-packages/tqdm/_tqdm.py", line 882, in del
File "/home/test/Anaconda3/envs/py35/lib/python3.5/site-packages/tqdm/_tqdm.py", line 1087, in close
File "/home/test/Anaconda3/envs/py35/lib/python3.5/site-packages/tqdm/_tqdm.py", line 439, in _decr_instances
File "/home/test/Anaconda3/envs/py35/lib/python3.5/_weakrefset.py", line 109, in remove
KeyError: <weakref at 0x7f686b4df598; to 'tqdm' at 0x7f686b53cd30>

Arabic text generator

Hi,

File names generated by the Arabic version of the repo are correct as the word letters are connected. However, text in images has disconnected letters and the words started from left to right. The text in an image should be started from right to left and the letter must be connected. Any suggestion on how to correct these issues?

Thanks

text-color is unable to apply

found a bug in text-color use.
add background = background.convert('RGBA') in data_generator.py at line 89 can fix this problem

Hollow letters when using handwritten

This is probably a regression as it does not show in the generated examples in the README.md.

nonliturgic_0

W can see when using a higher resolution that the letters are "hollow" in that there seems to be two lines per stoke instead of one bold line.

The color is also off grey-ish while it should be black. If possible the --text_color parameters should be supported as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.