19
19
train_lst , eval_lst = list (), list ()
20
20
font = ImageFont .truetype (random .choice (font_list )+ ".ttf" ,14 )
21
21
for i in range (args .train_num ):
22
- img = Image .new ("RGBA" , (110 ,20 ),(255 ,255 ,255 ))
23
- word = '' .join (random .choice (string .ascii_letters ) for i in range ( random . randrange ( 5 , 10 )) )
22
+ img = Image .new ("RGBA" , (20 ,20 ),(255 ,255 ,255 ))
23
+ word = '' .join (random .choice (string .ascii_letters ))
24
24
ImageDraw .Draw (img ).text ((5 , 0 ), word , (0 ,0 ,0 ), font = font )
25
25
img = np .array (img .convert ("L" ), dtype = np .float32 )
26
26
train_lst .append ((img , img + img * np .random .normal (0 ,1 ,img .size ).reshape (img .shape [0 ], img .shape [1 ]).astype ('uint8' )))
27
+ if i % 1000 == 0 : print ("Train image range " , i )
27
28
28
29
for i in range (args .eval_num ):
29
30
img = Image .new ("RGBA" , (110 ,20 ),(255 ,255 ,255 ))
30
31
word = '' .join (random .choice (string .ascii_letters ) for i in range (random .randrange (5 ,10 )))
31
32
ImageDraw .Draw (img ).text ((5 , 0 ), word , (0 ,0 ,0 ), font = font )
32
33
img = np .array (img .convert ("L" ), dtype = np .float32 )
33
34
eval_lst .append ((img , img + img * np .random .normal (0 ,1 ,img .size ).reshape (img .shape [0 ], img .shape [1 ]).astype ('uint8' )))
35
+ if i % 1000 == 0 : print ("Test image range " , i )
34
36
out1 , out2 = open (args .train_path , "wb" ), open (args .eval_path , "wb" )
35
37
pickle .dump (train_lst , out1 ), pickle .dump (eval_lst , out2 )
36
38
out1 .close (), out2 .close ()
0 commit comments