solivr / tf-crnn

TensorFlow convolutional recurrent neural network (CRNN) for text recognition
GNU General Public License v3.0
292 stars 98 forks source link

working with numbers only #27

Closed engahmed1190 closed 6 years ago

engahmed1190 commented 6 years ago

Hi @solivr

i would like to recognize numbers only , do i have to change in the parameters

parameters = Params(train_batch_size=128,
                            eval_batch_size=128,
                            learning_rate=1e-3,  # 1e-3 recommended
                            learning_decay_rate=0.95,
                            learning_decay_steps=5000,
                            evaluate_every_epoch=5,
                            save_interval=5e3,
                            input_shape=(32, 304),
                            optimizer='adam',
                            digits_only=False,
                            alphabet=Alphabet.LETTERS_DIGITS_EXTENDED,
                            alphabet_decoding='same',
                            csv_delimiter=';',
                            csv_files_eval=args.get('csv_files_eval'),
                            csv_files_train=args.get('csv_files_train'),
                            output_model_dir=args.get('output_model_dir'),
                            n_epochs=args.get('nb_epochs'),
                            gpu=args.get('gpu')
                            )  

is it mandatory to change digits_only to True

solivr commented 6 years ago

Hi @engahmed1190, To recognise numbers only you should change the alphabet to alphabet=Alphabet.DIGITS_ONLY. In fact I checked the digits_only flag and it seems it is deprecated and not used anymore (I'll update this in the next commit), so you shouldn't need to set it.

engahmed1190 commented 6 years ago

Thanks @solivr ! i have found you used tqdm but i can't found how much time is remaining for the training to finish.

in the code

for e in trange(0, parameters.n_epochs, parameters.evaluate_every_epoch):
    estimator.train(input_fn=data_loader(csv_filename=parameters.csv_files_train,
                                         params=parameters,
                                         batch_size=parameters.train_batch_size,
                                         num_epochs=parameters.evaluate_every_epoch,
                                         data_augmentation=True,
                                         image_summaries=True))
    estimator.evaluate(input_fn=data_loader(csv_filename=parameters.csv_files_eval,
                                            params=parameters,
                                            batch_size=parameters.eval_batch_size,
                                            num_epochs=1),
                       steps=np.floor(n_samples/parameters.eval_batch_size)
                       )

but the logging looks like that , do we have here global step for the training

2018-02-28 05:43:51.032314: I tensorflow/core/kernels/logging_ops.cc:79] * Loss : [18.023151]
2018-02-28 05:44:09.280180: I tensorflow/core/kernels/logging_ops.cc:79] * Loss : [18.568289]
2018-02-28 05:44:27.384644: I tensorflow/core/kernels/logging_ops.cc:79] * Loss : [17.58774]
2018-02-28 05:44:46.415241: I tensorflow/core/kernels/logging_ops.cc:79] * Loss : [18.446812]
2018-02-28 05:45:05.363675: I tensorflow/core/kernels/logging_ops.cc:79] * Loss : [17.554688]
2018-02-28 05:45:23.955595: I tensorflow/core/kernels/logging_ops.cc:79] * Loss : [17.988903]
2018-02-28 05:45:42.492874: I tensorflow/core/kernels/logging_ops.cc:79] * Loss : [16.457067]
2018-02-28 05:46:01.224872: I tensorflow/core/kernels/logging_ops.cc:79] * Loss : [18.016569]
2018-02-28 05:46:19.554097: I tensorflow/core/kernels/logging_ops.cc:79] * Loss : [17.401062]
2018-02-28 05:46:38.450462: I tensorflow/core/kernels/logging_ops.cc:79] * Loss : [19.39032]
2018-02-28 05:46:57.177618: I tensorflow/core/kernels/logging_ops.cc:79] * Loss : [18.329887]
2018-02-28 05:47:15.750723: I tensorflow/core/kernels/logging_ops.cc:79] * Loss : [18.674892]
2018-02-28 05:47:34.967545: I tensorflow/core/kernels/logging_ops.cc:79] * Loss : [18.348652]
2018-02-28 05:47:53.251881: I tensorflow/core/kernels/logging_ops.cc:79] * Loss : [18.124306]
2018-02-28 05:48:11.497463: I tensorflow/core/kernels/logging_ops.cc:79] * Loss : [18.184357]
2018-02-28 05:48:30.491427: I tensorflow/core/kernels/logging_ops.cc:79] * Loss : [16.317644]
engahmed1190 commented 6 years ago

also an error happens at the end

  File "train.py", line 102, in <module>
    steps=np.floor(n_samples/parameters.eval_batch_size)
  File "/home/paperspace/anaconda3/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 284, in evaluate
    raise ValueError('Must specify steps > 0, given: {}'.format(steps))
ValueError: Must specify steps > 0, given: 0.0
solivr commented 6 years ago

Have you provided a (non-empty) evaluation csv file ?

engahmed1190 commented 6 years ago

Yes , i have added some images and labels in the evaluation csv . Is it supposed to be Empty

solivr commented 6 years ago

Can you try to set as eval_csv_filethe same file you use for train_csv_file and tell me if you still get the same error (so -ft train_data.csv -fe train_data.csv when you launch the training) ?