solivr / tf-crnn

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

InavlidArgumentError when running prediction.py (tf2 branch) #56

Closed BryanOrabutt closed 5 years ago

BryanOrabutt commented 5 years ago

I have trained a model and was wanting to do some prediction on a set of images. When I run the predictor.py program I get the following output:

WARNING : The output directory ./output_model_large already exists.
2019-10-23 14:16:16.986893: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcuda.so.1
2019-10-23 14:16:16.993460: E tensorflow/stream_executor/cuda/cuda_driver.cc:318] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
2019-10-23 14:16:16.993519: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (borabut-arch): /proc/driver/nvidia/version does not exist
2019-10-23 14:16:16.994035: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-10-23 14:16:17.016236: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2395120000 Hz
2019-10-23 14:16:17.017044: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55f1df27e5b0 executing computations on platform Host. Devices:
2019-10-23 14:16:17.017136: I tensorflow/compiler/xla/service/service.cc:175]   StreamExecutor device (0): Host, Default Version
WARNING:tensorflow:From /home/borabutt/.conda/envs/crnn-tf2/lib/python3.6/site-packages/tensorflow_core/python/ops/image_ops_impl.py:1518: div (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Deprecated in favor of operator or tf.math.divide.
2019-10-23 14:16:21.531008: W tensorflow/core/framework/op_kernel.cc:1622] OP_REQUIRES failed at iterator_ops.cc:929 : Invalid argument: Expect 1 fields but have more in record
Traceback (most recent call last):
  File "prediction.py", line 40, in <module>
    prediction()
  File "/home/borabutt/.conda/envs/crnn-tf2/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/borabutt/.conda/envs/crnn-tf2/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/borabutt/.conda/envs/crnn-tf2/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/borabutt/.conda/envs/crnn-tf2/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "prediction.py", line 36, in prediction
    _, _, _ = model.predict(x=dataset_test, callbacks=[ps_callback])
  File "/home/borabutt/.conda/envs/crnn-tf2/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training.py", line 909, in predict
    use_multiprocessing=use_multiprocessing)
  File "/home/borabutt/.conda/envs/crnn-tf2/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training_generator.py", line 721, in predict
    model, x, steps=steps, verbose=verbose, workers=0, callbacks=callbacks)
  File "/home/borabutt/.conda/envs/crnn-tf2/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training_generator.py", line 221, in model_iteration
    batch_data = _get_next_batch(generator)
  File "/home/borabutt/.conda/envs/crnn-tf2/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training_generator.py", line 363, in _get_next_batch
    generator_output = next(generator)
  File "/home/borabutt/.conda/envs/crnn-tf2/lib/python3.6/site-packages/tensorflow_core/python/data/ops/iterator_ops.py", line 622, in __next__
    return self.next()
  File "/home/borabutt/.conda/envs/crnn-tf2/lib/python3.6/site-packages/tensorflow_core/python/data/ops/iterator_ops.py", line 666, in next
    return self._next_internal()
  File "/home/borabutt/.conda/envs/crnn-tf2/lib/python3.6/site-packages/tensorflow_core/python/data/ops/iterator_ops.py", line 651, in _next_internal
    output_shapes=self._flat_output_shapes)
  File "/home/borabutt/.conda/envs/crnn-tf2/lib/python3.6/site-packages/tensorflow_core/python/ops/gen_dataset_ops.py", line 2673, in iterator_get_next_sync
    _six.raise_from(_core._status_to_exception(e.code, message), None)
  File "<string>", line 3, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: Expect 1 fields but have more in record [Op:IteratorGetNextSync]

My .csv file that was specified to the input to predict.py contains the following

/home/borabutt/rotation1/eval_data/png/image0.png;8
/home/borabutt/rotation1/eval_data/png/image100.png;o
/home/borabutt/rotation1/eval_data/png/image101.png;9
/home/borabutt/rotation1/eval_data/png/image102.png;7
/home/borabutt/rotation1/eval_data/png/image103.png;-
/home/borabutt/rotation1/eval_data/png/image104.png;3
/home/borabutt/rotation1/eval_data/png/image105.png;8
/home/borabutt/rotation1/eval_data/png/image106.png;2
/home/borabutt/rotation1/eval_data/png/image107.png;g
/home/borabutt/rotation1/eval_data/png/image10.png;g
/home/borabutt/rotation1/eval_data/png/image11.png;9
/home/borabutt/rotation1/eval_data/png/image12.png;0
/home/borabutt/rotation1/eval_data/png/image13.png;2
/home/borabutt/rotation1/eval_data/png/image14.png;0
/home/borabutt/rotation1/eval_data/png/image15.png;5
/home/borabutt/rotation1/eval_data/png/image16.png;9
/home/borabutt/rotation1/eval_data/png/image17.png;3
/home/borabutt/rotation1/eval_data/png/image18.png;7
/home/borabutt/rotation1/eval_data/png/image19.png;0
/home/borabutt/rotation1/eval_data/png/image1.png;8

Any and all help is appreciated.

BryanOrabutt commented 5 years ago

Solved it. Did not realize the csv file format for prediction.py was different. In hindsight it makes sense. The ;<string chars> is not needed, just terminate each file path with a new line.