Belval / TextRecognitionDataGenerator

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

FreeFontType error #343

Open sull1vn opened 1 month ago

sull1vn commented 1 month ago

When I try to generate images from the CLI using trdg -c 1000 -w 5 -f 64 or a custom Python script I get AttributeError: 'FreeTypeFont' object has no attribute 'getsize'. Specifically on File "C:\Program Files\Python312\Lib\multiprocessing\pool.py", line 125, in worker result = (True, func(*args, **kwds)) ^^^^^^^^^^^^^^^^^^^ File "C:\Users\\AppData\Roaming\Python\Python312\site-packages\trdg\data_generator.py", line 22, in generate_from_tuple cls.generate(*t) File "C:\Users\\AppData\Roaming\Python\Python312\site-packages\trdg\data_generator.py", line 72, in generate image, mask = computer_text_generator.generate( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\y\AppData\Roaming\Python\Python312\site-packages\trdg\computer_text_generator.py", line 36, in generate return _generate_horizontal_text( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\\AppData\Roaming\Python\Python312\site-packages\trdg\computer_text_generator.py", line 107, in _generate_horizontal_text text_height = max([get_text_height(image_font, p) for p in splitted_text]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\\AppData\Roaming\Python\Python312\site-packages\trdg\utils.py", line 122, in get_text_height return image_font.getsize(text)[1]

patrikdh commented 1 month ago

reinstalling the Pillow package to 9.5 version fixed this error for me