weinman / cnn_lstm_ctc_ocr

Tensorflow-based CNN+LSTM trained with CTC-loss for OCR
GNU General Public License v3.0
497 stars 170 forks source link

TypeError: __init__() got an unexpected keyword argument 'session_config'` #44

Closed lijian-1994 closed 5 years ago

lijian-1994 commented 5 years ago

when i run validate.py,i encounter an error: D:\Tensorflow\cnn_lstm_ctc_ocr-master\src>python validate.py d:/Tensorflow/cnn_lstm_ctc_ocr_master/src/11.jpg d:\Anaconda3\lib\site-packages\h5py\__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype fromfloattonp.floatingis deprecated. In future, it will be treated asnp.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters Traceback (most recent call last): File "validate.py", line 109, in <module> tf.app.run() File "d:\Anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "validate.py", line 89, in main classifier = tf.estimator.Estimator( config=_get_config(), File "validate.py", line 82, in _get_config custom_config = tf.estimator.RunConfig( session_config=device_config ) TypeError: __init__() got an unexpected keyword argument 'session_config' my tensorflow version is 1.2.1,windows

lijian-1994 commented 5 years ago

when i run train.py,another error encounted: python train.py /home/cs316/anaconda3/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype fromfloattonp.floatingis deprecated. In future, it will be treated asnp.float64 == np.dtype(float).type. from ._conv import register_converters as _register_converters INFO:tensorflow:Using config: {'_model_dir': '../data/model', '_tf_random_seed': None, '_save_summary_steps': 100, '_save_checkpoints_steps': None, '_save_checkpoints_secs': 120, '_session_config': allow_soft_placement: true , '_keep_checkpoint_max': 5, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 100, '_train_distribute': None, '_device_fn': None, '_protocol': None, '_eval_distribute': None, '_experimental_distribute': None, '_service': None, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7f1fac3ceda0>, '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1} Traceback (most recent call last): File "train.py", line 182, in <module> tf.app.run() File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 125, in run _sys.exit(main(argv)) File "train.py", line 179, in main classifier.train( input_fn=_get_input, max_steps=FLAGS.max_num_steps ) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 356, in train loss = self._train_model(input_fn, hooks, saving_listeners) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 1181, in _train_model return self._train_model_default(input_fn, hooks, saving_listeners) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 1208, in _train_model_default input_fn, model_fn_lib.ModeKeys.TRAIN)) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 1049, in _get_features_and_labels_from_input_fn self._call_input_fn(input_fn, mode)) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 1136, in _call_input_fn return input_fn(**kwargs) File "train.py", line 130, in _get_input dataset = pipeline.get_data( FLAGS.static_data, **data_args) File "/home/cs316/lijian/cnn_lstm_ctc_ocr-master/src/pipeline.py", line 79, in get_data dataset = dpipe.get_dataset( dpipe_args ) File "/home/cs316/lijian/cnn_lstm_ctc_ocr-master/src/mjsynth.py", line 60, in get_dataset buffer_size=buffer_sz ) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/data/ops/readers.py", line 212, in __init__ prefetch_input_elements=None) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/data/ops/readers.py", line 128, in __init__ cycle_length, block_length) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 2312, in __init__ super(InterleaveDataset, self).__init__(input_dataset, map_func) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 2275, in __init__ experimental_nested_dataset_support=True) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1473, in __init__ self._function.add_to_graph(ops.get_default_graph()) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 479, in add_to_graph self._create_definition_if_needed() File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 335, in _create_definition_if_needed self._create_definition_if_needed_impl() File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 344, in _create_definition_if_needed_impl self._capture_by_value, self._caller_device) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/function.py", line 865, in func_graph_from_py_func outputs = func(*func_graph.inputs) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1411, in tf_data_structured_function_wrapper ret = func(*nested_args) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/data/ops/readers.py", line 204, in read_one_file return _TFRecordDataset(filename, compression_type, buffer_size) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/data/ops/readers.py", line 102, in __init__ argument_default=_DEFAULT_READER_BUFFER_SIZE_BYTES) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/data/util/convert.py", line 32, in optional_param_to_tensor argument_value, dtype=argument_dtype, name=argument_name) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1048, in convert_to_tensor as_ref=False) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1144, in internal_convert_to_tensor ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 228, in _constant_tensor_conversion_function return constant(v, dtype=dtype, name=name) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 207, in constant value, dtype=dtype, shape=shape, verify_shape=verify_shape)) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 442, in make_tensor_proto _AssertCompatible(values, dtype) File "/home/cs316/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 353, in _AssertCompatible (dtype.name, repr(mismatch), type(mismatch).__name__)) TypeError: Expected int64, got 64.0 of type 'float' instead. cs316@cs316-ProLiant-ML350-Gen9:~/lijian/cnn_lstm_ctc_ocr-master/src$ python Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19) [GCC 7.2.0] on linux

weinman commented 5 years ago

Thank you for the report. I believe TF 1.2 is far too old a version to use for this package. You should upgrade to at least 1.10 (1.11 if you want to train with multiple GPUs).

If that's impossible and you're determined to use this software, you can try the old version (checkout tag tf-1.2) which is radically different in I/O structure (see HISTORY)

weinman commented 5 years ago

Also, the scripts are written for Python 2.7; I have no idea whether they will work in Python3.

lijian-1994 commented 5 years ago

@weinman thanks for your answer! i have solved the first error,but i got another error when i run train.py.the error just like the second question above. run in linux,python3.6,tensorflow 1.10.

weinman commented 5 years ago

I don't have time right now to dig deeply into this, but it looks like maybe a problem with Tensorflow's Python3 version, rather than a problem with this particular repo's code. Can you try with Python2.7?

lijian-1994 commented 5 years ago

@weinman I have solved it by try with Python2.7.Thank you!

weinman commented 5 years ago

Thanks for following up.