@@ -172,7 +172,7 @@ def __init__(self,
172
172
)
173
173
174
174
insert = table .insert (
175
- tf .constant (range (len (DataGen .CHARMAP )), dtype = tf .int64 ),
175
+ tf .constant (list ( range (len (DataGen .CHARMAP ) )), dtype = tf .int64 ),
176
176
tf .constant (DataGen .CHARMAP ),
177
177
)
178
178
@@ -425,17 +425,17 @@ def visualize_attention(self, filename, attentions, output, label, flag_incorrec
425
425
(mw , h ),
426
426
Image .ANTIALIAS )
427
427
img_data = np .asarray (img , dtype = np .uint8 )
428
- for idx in range (len (output )):
428
+ for idx in xrange (len (output )):
429
429
output_filename = os .path .join (output_dir , 'image_%d.jpg' % (idx ))
430
430
attention = attentions [idx ][:(int (mw / 4 )- 1 )]
431
431
attention_orig = np .zeros (mw )
432
- for i in range (mw ):
432
+ for i in xrange (mw ):
433
433
if i / 4 - 1 > 0 and i / 4 - 1 < len (attention ):
434
434
attention_orig [i ] = attention [int (i / 4 )- 1 ]
435
435
attention_orig = np .convolve (attention_orig , [0.199547 , 0.200226 , 0.200454 , 0.200226 , 0.199547 ], mode = 'same' )
436
436
attention_orig = np .maximum (attention_orig , 0.3 )
437
437
attention_out = np .zeros ((h , mw ))
438
- for i in range (mw ):
438
+ for i in xrange (mw ):
439
439
attention_out [:, i ] = attention_orig [i ]
440
440
if len (img_data .shape ) == 3 :
441
441
attention_out = attention_out [:, :, np .newaxis ]
0 commit comments