emedvedev / attention-ocr

A Tensorflow model for text recognition (CNN + seq2seq with visual attention) available as a Python package and compatible with Google Cloud ML Engine.
MIT License
1.08k stars 256 forks source link

decoder_inputs' first element is not matched with GO flag's index #131

Closed Harmonicahappy closed 5 years ago

Harmonicahappy commented 5 years ago

First of all, you define GO flag's index as 1 in data_gen.py:

class DataGen(object):
    GO_ID = 1
    EOS_ID = 2
    IMAGE_HEIGHT = 32
    CHARMAP = ['', '', ''] + list('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ')

Second, decoder_inputs will be filled with value 0 in model.py:

self.decoder_inputs = []
self.target_weights = []
for i in xrange(self.decoder_size + 1):
    self.decoder_inputs.append(
        tf.tile([0], [num_images])
    )

In train mode, it is ok because decoder_inputs will be filled with ground truth labels, but in predict mode, first element of decoder_inputs will be 0, and it is not the correct index for GO flag. Am I right?

emedvedev commented 5 years ago

Fixed in https://github.com/emedvedev/attention-ocr/pull/132