tensorflow / models

Models and examples built with TensorFlow
Other
77.16k stars 45.75k forks source link

testing attention_ocr model on test set: getting "TypeError: The value of a feed cannot be a tf.Tensor object. Acceptable feed values include Python scalars, strings, lists, numpy ndarrays, or TensorHandles" #1620

Closed tumusudheer closed 7 years ago

tumusudheer commented 7 years ago

System information

Describe the problem

I was trying to use the pretrained model of attention_ocr (model.ckpt-399731) on test data (fsn data). My idea was once I'm able to run it successfully, I can try it on my own images.

But when I followed the provided instructions to use pretrained model, I'm getting the following error: Traceback (most recent call last): File "test.py", line 60, in <module> app.run() File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "test.py", line 54, in main predictions = sess.run(endpoints.predicted_chars, feed_dict={img_data:data.images}) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 778, in run run_metadata_ptr) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 936, in _run raise TypeError('The value of a feed cannot be a tf.Tensor object. ' TypeError: The value of a feed cannot be a tf.Tensor object. Acceptable feed values include Python scalars, strings, lists, numpy ndarrays, or TensorHandles.

Here are the steps I followed:

I'm getting the error in the last line when running predictions.

Source code

Please find the complete source code `def main(_):

img_data = tf.placeholder(tf.float32, shape=(32, 150, 600, 3), name='img_data')
dataset = common_flags.create_dataset(split_name='test')
data = data_provider.get_data(dataset, FLAGS.batch_size, augment=False, central_crop_size=common_flags.get_crop_size())

with tf.Session() as sess:

    model = common_flags.create_model(dataset.num_char_classes,
                                dataset.max_sequence_length,
                                dataset.num_of_views, dataset.null_code)
    endpoints = model.create_base(img_data, labels_one_hot=None)
    total_loss = model.create_loss(data, endpoints)
    summaries = model.create_summaries(data, endpoints, dataset.charset, is_training=False)
    init_fn = model.create_init_fn_to_restore(FLAGS.checkpoint, FLAGS.checkpoint_inception)
    #sess.run(tf.global_variables_initializer())
    #print init_fn
    predictions = sess.run(endpoints.predicted_chars, feed_dict={img_data:data.images})

`

Logs

Please find the complete stack trace: INFO 2017-06-20 02:49:57.000398: fsns.py: 130 Using FSNS dataset split_name=test dataset_dir=/home/sudheer/Flipkart/Research/maneesh/tensor_flow/models/models/attention_ocr/python/datasets/data/fsns 2017-06-20 02:49:57.519862: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations. 2017-06-20 02:49:57.519882: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. 2017-06-20 02:49:57.519889: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. 2017-06-20 02:49:57.519894: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. 2017-06-20 02:49:57.519898: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. 2017-06-20 02:49:57.798192: I tensorflow/core/common_runtime/gpu/gpu_device.cc:887] Found device 0 with properties: name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate (GHz) 1.8095 pciBusID 0000:01:00.0 Total memory: 7.92GiB Free memory: 7.64GiB 2017-06-20 02:49:57.798225: I tensorflow/core/common_runtime/gpu/gpu_device.cc:908] DMA: 0 2017-06-20 02:49:57.798232: I tensorflow/core/common_runtime/gpu/gpu_device.cc:918] 0: Y 2017-06-20 02:49:57.798241: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0) DEBUG 2017-06-20 02:49:57.000835: model.py: 314 images: Tensor("img_data:0", shape=(32, 150, 600, 3), dtype=float32) DEBUG 2017-06-20 02:49:57.000837: model.py: 319 Views=4 single view: Tensor("AttentionOcr_v1/split:0", shape=(32, 150, 150, 3), dtype=float32) DEBUG 2017-06-20 02:49:57.000837: model.py: 186 Using final_endpoint=Mixed_5d DEBUG 2017-06-20 02:49:58.000554: model.py: 186 Using final_endpoint=Mixed_5d DEBUG 2017-06-20 02:49:58.000940: model.py: 186 Using final_endpoint=Mixed_5d DEBUG 2017-06-20 02:49:59.000301: model.py: 186 Using final_endpoint=Mixed_5d DEBUG 2017-06-20 02:49:59.000722: model.py: 325 Conv tower: Tensor("AttentionOcr_v1/conv_tower_fn/INCE/InceptionV3/Mixed_5d/concat:0", shape=(32, 16, 16, 288), dtype=float32) DEBUG 2017-06-20 02:49:59.000724: model.py: 328 Pooled views: Tensor("AttentionOcr_v1/pool_views_fn/STCK/Reshape:0", shape=(32, 1024, 288), dtype=float32) DEBUG 2017-06-20 02:49:59.000724: sequence_layers.py: 421 Use AttentionWithAutoregression as a layer class DEBUG 2017-06-20 02:50:00.000818: model.py: 331 chars_logit: Tensor("AttentionOcr_v1/sequence_logit_fn/SQLR/concat:0", shape=(32, 37, 134), dtype=float32) WARNING:tensorflow:From /home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/models/attention_ocr/python/model.py:358: get_total_loss (from tensorflow.contrib.losses.python.losses.loss_ops) is deprecated and will be removed after 2016-12-30. Instructions for updating: Use tf.losses.get_total_loss instead. WARNING 2017-06-20 02:50:01.000253: deprecation.py: 117 From /home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/models/attention_ocr/python/model.py:358: get_total_loss (from tensorflow.contrib.losses.python.losses.loss_ops) is deprecated and will be removed after 2016-12-30. Instructions for updating: Use tf.losses.get_total_loss instead. WARNING:tensorflow:From /home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/contrib/losses/python/losses/loss_ops.py:261: get_losses (from tensorflow.contrib.losses.python.losses.loss_ops) is deprecated and will be removed after 2016-12-30. Instructions for updating: Use tf.losses.get_losses instead. WARNING 2017-06-20 02:50:01.000253: deprecation.py: 117 From /home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/contrib/losses/python/losses/loss_ops.py:261: get_losses (from tensorflow.contrib.losses.python.losses.loss_ops) is deprecated and will be removed after 2016-12-30. Instructions for updating: Use tf.losses.get_losses instead. WARNING:tensorflow:From /home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/contrib/losses/python/losses/loss_ops.py:263: get_regularization_losses (from tensorflow.contrib.losses.python.losses.loss_ops) is deprecated and will be removed after 2016-12-30. Instructions for updating: Use tf.losses.get_regularization_losses instead. WARNING 2017-06-20 02:50:01.000253: deprecation.py: 117 From /home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/contrib/losses/python/losses/loss_ops.py:263: get_regularization_losses (from tensorflow.contrib.losses.python.losses.loss_ops) is deprecated and will be removed after 2016-12-30. Instructions for updating: Use tf.losses.get_regularization_losses instead. INFO 2017-06-20 02:50:01.000279: model.py: 511 Request to re-store 116 weights from model.ckpt-399731 INFO 2017-06-20 02:50:01.000462: model.py: 511 Request to re-store 104 weights from /home/sudheer/Flipkart/Research/maneesh/tensor_flow/models/models/attention_ocr/python/pretrained_models/inception_v3.ckpt Traceback (most recent call last): File "test.py", line 60, in <module> app.run() File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "test.py", line 54, in main predictions = sess.run(endpoints.predicted_chars, feed_dict={img_data:data.images}) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 778, in run run_metadata_ptr) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 936, in _run raise TypeError('The value of a feed cannot be a tf.Tensor object. ' TypeError: The value of a feed cannot be a tf.Tensor object. Acceptable feed values include Python scalars, strings, lists, numpy ndarrays, or TensorHandles.

Please let me know if I'm doing something wrong and how should I fix my code. If anyone has successfully used pretrained attention_ocr model to test on their images, I really appreciate if you can provide me the python script you used or series of steps I need to follow to do the same.

tumusudheer commented 7 years ago

Hi, Can someone please help me on this issue. Thank you.

alexgorban commented 7 years ago

The error happens because you provide a tf.Tensor (data.images) instead of an actual data (numpy ndarray) to feed into the placeholder. But the good news are you don't need to create a placeholder at all to run the model on the FSNS test data, just use the data.images directly:

dataset = common_flags.create_dataset(split_name='test')
data = data_provider.get_data(dataset, FLAGS.batch_size, augment=False, central_crop_size=common_flags.get_crop_size())
model = common_flags.create_model(dataset.num_char_classes,
                                dataset.max_sequence_length,
                                dataset.num_of_views, dataset.null_code)
endpoints = model.create_base(data.images, labels_one_hot=None)

with tf.Session() as sess:
    ...
    predictions = sess.run(endpoints.predicted_chars)
tumusudheer commented 7 years ago

Hi @alexgorban,

Thank you very much. I've tried your fix. But I'm getting different error now: tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value AttentionOcr_v1/conv_tower_fn/INCE/InceptionV3/Conv2d_1a_3x3/weights [[Node: AttentionOcr_v1/conv_tower_fn/INCE/InceptionV3/Conv2d_1a_3x3/weights/read = IdentityT=DT_FLOAT, _class=["loc:@AttentionOcr_v1/conv_tower_fn/INCE/InceptionV3/Conv2d_1a_3x3/weights"], _device="/job:localhost/replica:0/task:0/gpu:0"]]

Here is my code: ` dataset = common_flags.create_dataset(split_name='test')

data = data_provider.get_data(dataset, FLAGS.batch_size, augment=False, central_crop_size=common_flags.get_crop_size())
model = common_flags.create_model(dataset.num_char_classes,
                            dataset.max_sequence_length,
                            dataset.num_of_views, dataset.null_code)

endpoints = model.create_base(data.images, labels_one_hot=None)

init_fn = model.create_init_fn_to_restore(FLAGS.checkpoint, FLAGS.checkpoint_inception)

predictions = sess.run(endpoints.predicted_chars)

`

Please see the complete log here: `DEBUG 2017-06-27 02:47:06.000249: model.py: 314 images: Tensor("shuffle_batch:0", shape=(32, 150, 600, 3), dtype=float32) DEBUG 2017-06-27 02:47:06.000250: model.py: 319 Views=4 single view: Tensor("AttentionOcr_v1/split:0", shape=(32, 150, 150, 3), dtype=float32) DEBUG 2017-06-27 02:47:06.000250: model.py: 186 Using final_endpoint=Mixed_5d DEBUG 2017-06-27 02:47:06.000891: model.py: 186 Using final_endpoint=Mixed_5d DEBUG 2017-06-27 02:47:07.000252: model.py: 186 Using final_endpoint=Mixed_5d DEBUG 2017-06-27 02:47:07.000662: model.py: 186 Using final_endpoint=Mixed_5d DEBUG 2017-06-27 02:47:08.000084: model.py: 325 Conv tower: Tensor("AttentionOcr_v1/conv_tower_fn/INCE/InceptionV3/Mixed_5d/concat:0", shape=(32, 16, 16, 288), dtype=float32) DEBUG 2017-06-27 02:47:08.000086: model.py: 328 Pooled views: Tensor("AttentionOcr_v1/pool_views_fn/STCK/Reshape:0", shape=(32, 1024, 288), dtype=float32) DEBUG 2017-06-27 02:47:08.000086: sequence_layers.py: 421 Use AttentionWithAutoregression as a layer class DEBUG 2017-06-27 02:47:09.000189: model.py: 331 chars_logit: Tensor("AttentionOcr_v1/sequence_logit_fn/SQLR/concat:0", shape=(32, 37, 134), dtype=float32) 2017-06-27 02:47:09.209585: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations. 2017-06-27 02:47:09.209596: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. 2017-06-27 02:47:09.209599: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. 2017-06-27 02:47:09.209602: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. 2017-06-27 02:47:09.209605: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. 2017-06-27 02:47:09.422637: I tensorflow/core/common_runtime/gpu/gpu_device.cc:887] Found device 0 with properties: name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate (GHz) 1.8095 pciBusID 0000:01:00.0 Total memory: 7.92GiB Free memory: 7.80GiB 2017-06-27 02:47:09.422661: I tensorflow/core/common_runtime/gpu/gpu_device.cc:908] DMA: 0 2017-06-27 02:47:09.422665: I tensorflow/core/common_runtime/gpu/gpu_device.cc:918] 0: Y 2017-06-27 02:47:09.422670: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0) INFO 2017-06-27 02:47:09.000447: model.py: 511 Request to re-store 116 weights from model.ckpt-399731 INFO 2017-06-27 02:47:09.000542: model.py: 511 Request to re-store 104 weights from /home/sudheer/Flipkart/Research/maneesh/tensor_flow/models/models/attention_ocr/python/pretrained_models/inception_v3.ckpt 2017-06-27 02:47:10.229472: W tensorflow/core/kernels/queue_base.cc:302] _0_shuffle_batch/random_shuffle_queue: Skipping cancelled dequeue attempt with queue not closed Traceback (most recent call last): File "test.py", line 70, in app.run() File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "test.py", line 66, in main predictions = sess.run(endpoints.predicted_chars) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 778, in run run_metadata_ptr) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 982, in _run feed_dict_string, options, run_metadata) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1032, in _do_run target_list, options, run_metadata) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1052, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.FailedPreconditionError: Attempting to use uninitialized value AttentionOcr_v1/conv_tower_fn/INCE/InceptionV3/Conv2d_1a_3x3/weights [[Node: AttentionOcr_v1/conv_tower_fn/INCE/InceptionV3/Conv2d_1a_3x3/weights/read = IdentityT=DT_FLOAT, _class=["loc:@AttentionOcr_v1/conv_tower_fn/INCE/InceptionV3/Conv2d_1a_3x3/weights"], _device="/job:localhost/replica:0/task:0/gpu:0"]] [[Node: AttentionOcr_v1/predicted_chars/_3 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_7630_AttentionOcr_v1/predicted_chars", tensor_type=DT_INT32, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

Caused by op u'AttentionOcr_v1/conv_tower_fn/INCE/InceptionV3/Conv2d_1a_3x3/weights/read', defined at: File "test.py", line 70, in app.run() File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "test.py", line 63, in main endpoints = model.create_base(data.images, labels_one_hot=None) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/models/attention_ocr/python/model.py", line 323, in create_base for i, v in enumerate(views) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/models/attention_ocr/python/model.py", line 192, in conv_tower_fn images, final_endpoint=mparams.final_endpoint) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/contrib/slim/python/slim/nets/inception_v3.py", line 111, in inception_v3_base net = layers.conv2d(inputs, depth(32), [3, 3], stride=2, scope=end_point) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 181, in func_with_args return func(args, current_args) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/contrib/layers/python/layers/layers.py", line 918, in convolution outputs = layer.apply(inputs) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/layers/base.py", line 320, in apply return self.call(inputs, kwargs) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/layers/base.py", line 286, in call self.build(input_shapes[0]) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/layers/convolutional.py", line 138, in build dtype=self.dtype) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 1049, in get_variable use_resource=use_resource, custom_getter=custom_getter) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 948, in get_variable use_resource=use_resource, custom_getter=custom_getter) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 349, in get_variable validate_shape=validate_shape, use_resource=use_resource) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 1389, in wrapped_custom_getter args, kwargs) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/layers/base.py", line 275, in variable_getter variable_getter=functools.partial(getter, kwargs)) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/layers/base.py", line 228, in _add_variable trainable=trainable and self.trainable) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1334, in layer_variable_getter return _model_variable_getter(getter, *args, kwargs) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/contrib/layers/python/layers/layers.py", line 1326, in _model_variable_getter custom_getter=getter, use_resource=use_resource) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 181, in func_with_args return func(*args, *current_args) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 262, in model_variable use_resource=use_resource) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/arg_scope.py", line 181, in func_with_args return func(args, current_args) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 217, in variable use_resource=use_resource) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 341, in _true_getter use_resource=use_resource) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/ops/variable_scope.py", line 714, in _get_single_variable validate_shape=validate_shape) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 197, in init expected_shape=expected_shape) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/ops/variables.py", line 316, in _init_from_args self._snapshot = array_ops.identity(self._variable, name="read") File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 1338, in identity result = _op_def_lib.apply_op("Identity", input=input, name=name) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 768, in apply_op op_def=op_def) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2336, in create_op original_op=self._default_original_op, op_def=op_def) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1228, in init self._traceback = _extract_stack()

FailedPreconditionError (see above for traceback): Attempting to use uninitialized value AttentionOcr_v1/conv_tower_fn/INCE/InceptionV3/Conv2d_1a_3x3/weights [[Node: AttentionOcr_v1/conv_tower_fn/INCE/InceptionV3/Conv2d_1a_3x3/weights/read = IdentityT=DT_FLOAT, _class=["loc:@AttentionOcr_v1/conv_tower_fn/INCE/InceptionV3/Conv2d_1a_3x3/weights"], _device="/job:localhost/replica:0/task:0/gpu:0"]] [[Node: AttentionOcr_v1/predicted_chars/_3 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_7630_AttentionOcr_v1/predicted_chars", tensor_type=DT_INT32, _device="/job:localhost/replica:0/task:0/cpu:0"]()]] `

alexgorban commented 7 years ago

It looks like you created the initialization part of the graph referred by the init_fn tensor, but you didn't actually used it. Try to call sess.run(init_fn) before predictions = sess.run(endpoints.predicted_chars).

tumusudheer commented 7 years ago

hi @alexgorban,

Thank you very much. I tried doing as you said, calling sess.run(init_fn)

    with tf.Session() as sess:
        init_fn = model.create_init_fn_to_restore(FLAGS.checkpoint, FLAGS.checkpoint_inception)
        sess.run(init_fn)
        predictions = sess.run(endpoints.predicted_chars)

I'm getting the following error: I must be very close to getting it working. I'm sorry as I'm a new user to TF. Please let me know how to resolve the following error.

Traceback (most recent call last): File "test.py", line 74, in app.run() File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "test.py", line 69, in main sess.run(init_fn) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 778, in run run_metadata_ptr) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 969, in _run fetch_handler = _FetchHandler(self._graph, fetches, feed_dict_string) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 408, in init self._fetch_mapper = _FetchMapper.for_fetch(fetches) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 238, in for_fetch return _ElementFetchMapper(fetches, contraction_fn) File "/home/sudheer/Flipkart/Research/maneesh/tensorflow_1.1/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 271, in init % (fetch, type(fetch), str(e))) TypeError: Fetch argument <function init_assign_fn at 0x7f6234571f50> has invalid type <type 'function'>, must be a string or Tensor. (Can not convert a function into a Tensor or Operation.)

Thank you in advance.

ali01 commented 7 years ago

This question is better asked on StackOverflow since it is not a bug or feature request. There is also a larger community that reads questions there. Thanks!