Belval / TextRecognitionDataGenerator

A synthetic data generator for text recognition
MIT License
3.15k stars 943 forks source link

How to specify the font to be used? #304

Open 2catycm opened 1 year ago

2catycm commented 1 year ago

My need is really simple, given a text and a ttf font file, output the images augmented. However, the example in README.md does not work as I expected.

After I read your doc, I think the following code should be correct,

from trdg.generators import (
    GeneratorFromDict,
    GeneratorFromRandom,
    GeneratorFromStrings,
    GeneratorFromWikipedia,
)

# The generators use the same arguments as the CLI, only as parameters
generator = GeneratorFromStrings(
    ['Test1', 'Test2', 'Test3'],
    blur=2,
    random_blur=True, 
    fonts = load_fonts('my_font_folder')
    language = 'my_font_folder'
)

However, the trdg just ignore 'my_font_folder', it just uses the fonts in 'en' folder and use en language

2catycm commented 1 year ago

ttf files are in the 'my_font_folder'

rdavis22 commented 1 year ago

Did you ever resolve this issue? I am looking at the same problem.

Deeksha-5 commented 1 year ago

Try mentioning the .ttf file in the font parameter and the path to the font folder in the font directory parameter