Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsuccessful TensorSliceReader constructor: Failed to find any matching files for /home/harsh/Documents/model_fcn8s_final.ckpt #39

Open
Harsh2040 opened this issue Jan 29, 2018 · 1 comment

Comments

@Harsh2040
Copy link

Harsh2040 commented Jan 29, 2018

`%matplotlib inline

from future import division

import os
import sys
import tensorflow as tf
import skimage.io as io
import numpy as np

sys.path.append("/home/harsh/Documents/models/research/slim/")

fcn_16s_checkpoint_path = '/home/harsh/Documents/model_fcn8s_final.ckpt'

os.environ["CUDA_VISIBLE_DEVICES"] = '1'

slim = tf.contrib.slim

sys.path.append("/home/harsh/Documents/")
from tf_image_segmentation.models.fcn_8s import FCN_8s
from tf_image_segmentation.utils.inference import adapt_network_for_any_size_input
from tf_image_segmentation.utils.pascal_voc import pascal_segmentation_lut

number_of_classes = 2

image_filename = './17.jpg'

#image_filename = 'small_cat.jpg'

image_filename_placeholder = tf.placeholder(tf.string)

feed_dict_to_use = {image_filename_placeholder: image_filename}

image_tensor = tf.read_file(image_filename_placeholder)

image_tensor = tf.image.decode_jpeg(image_tensor, channels=3)

Fake batch for image and annotation by adding

leading empty axis.

image_batch_tensor = tf.expand_dims(image_tensor, axis=0)

Be careful: after adaptation, network returns final labels

and not logits

FCN_8s = adapt_network_for_any_size_input(FCN_8s, 32)

pred, fcn_16s_variables_mapping = FCN_8s(image_batch_tensor=image_batch_tensor,
number_of_classes=number_of_classes,
is_training=False)

The op for initializing the variables.

initializer = tf.local_variables_initializer()

saver = tf.train.Saver()

with tf.Session() as sess:

sess.run(initializer)


saver.restore(sess, fcn_16s_checkpoint_path)
print("Model restored.")

image_np, pred_np = sess.run([image_tensor, pred], feed_dict=feed_dict_to_use)


io.imshow(image_np)
io.show()

io.imshow(pred_np.squeeze())
io.show()`

I'm getting this error.

`NotFoundError: Unsuccessful TensorSliceReader constructor: Failed to find any matching files for /home/harsh/Documents/model_fcn8s_final.ckpt
[[Node: save/RestoreV2_2 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save/Const_0_0, save/RestoreV2_2/tensor_names, save/RestoreV2_2/shape_and_slices)]]

Caused by op 'save/RestoreV2_2', defined at:
File "/home/harsh/anaconda3/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"main", mod_spec)
File "/home/harsh/anaconda3/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/harsh/.local/lib/python3.5/site-packages/ipykernel/main.py", line 3, in
app.launch_new_instance()
File "/home/harsh/.local/lib/python3.5/site-packages/traitlets/config/application.py", line 658, in launch_instance
app.start()
File "/home/harsh/.local/lib/python3.5/site-packages/ipykernel/kernelapp.py", line 477, in start
ioloop.IOLoop.instance().start()
File "/home/harsh/.local/lib/python3.5/site-packages/zmq/eventloop/ioloop.py", line 177, in start
super(ZMQIOLoop, self).start()
File "/home/harsh/.local/lib/python3.5/site-packages/tornado/ioloop.py", line 888, in start
handler_func(fd_obj, events)
File "/home/harsh/.local/lib/python3.5/site-packages/tornado/stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "/home/harsh/.local/lib/python3.5/site-packages/zmq/eventloop/zmqstream.py", line 440, in _handle_events
self._handle_recv()
File "/home/harsh/.local/lib/python3.5/site-packages/zmq/eventloop/zmqstream.py", line 472, in _handle_recv
self._run_callback(callback, msg)
File "/home/harsh/.local/lib/python3.5/site-packages/zmq/eventloop/zmqstream.py", line 414, in _run_callback
callback(*args, **kwargs)
File "/home/harsh/.local/lib/python3.5/site-packages/tornado/stack_context.py", line 277, in null_wrapper
return fn(*args, **kwargs)
File "/home/harsh/.local/lib/python3.5/site-packages/ipykernel/kernelbase.py", line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "/home/harsh/.local/lib/python3.5/site-packages/ipykernel/kernelbase.py", line 235, in dispatch_shell
handler(stream, idents, msg)
File "/home/harsh/.local/lib/python3.5/site-packages/ipykernel/kernelbase.py", line 399, in execute_request
user_expressions, allow_stdin)
File "/home/harsh/.local/lib/python3.5/site-packages/ipykernel/ipkernel.py", line 196, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "/home/harsh/.local/lib/python3.5/site-packages/ipykernel/zmqshell.py", line 533, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "/home/harsh/.local/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 2728, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "/home/harsh/.local/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 2850, in run_ast_nodes
if self.run_code(code, result):
File "/home/harsh/.local/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 2910, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 55, in
saver = tf.train.Saver()
File "/home/harsh/anaconda3/lib/python3.5/site-packages/tensorflow/python/training/saver.py", line 1140, in init
self.build()
File "/home/harsh/anaconda3/lib/python3.5/site-packages/tensorflow/python/training/saver.py", line 1172, in build
filename=self._filename)
File "/home/harsh/anaconda3/lib/python3.5/site-packages/tensorflow/python/training/saver.py", line 688, in build
restore_sequentially, reshape)
File "/home/harsh/anaconda3/lib/python3.5/site-packages/tensorflow/python/training/saver.py", line 407, in _AddRestoreOps
tensors = self.restore_op(filename_tensor, saveable, preferred_shard)
File "/home/harsh/anaconda3/lib/python3.5/site-packages/tensorflow/python/training/saver.py", line 247, in restore_op
[spec.tensor.dtype])[0])
File "/home/harsh/anaconda3/lib/python3.5/site-packages/tensorflow/python/ops/gen_io_ops.py", line 663, in restore_v2
dtypes=dtypes, name=name)
File "/home/harsh/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py", line 767, in apply_op
op_def=op_def)
File "/home/harsh/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 2630, in create_op
original_op=self._default_original_op, op_def=op_def)

File "/home/harsh/anaconda3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 1204, in init
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

NotFoundError (see above for traceback): Unsuccessful TensorSliceReader constructor: Failed to find any matching files for /home/harsh/Documents/model_fcn8s_final.ckpt
[[Node: save/RestoreV2_2 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save/Const_0_0, save/RestoreV2_2/tensor_names, save/RestoreV2_2/shape_and_slices)]]`

Can anyone fix this issue?

@EvilPerfectionist
Copy link

EvilPerfectionist commented Mar 19, 2018

Hi, please change 'model_fcn8s_final.ckpt' to 'model_'fcn8s_final.ckpt.index' or 'fcn8s_final.ckpt.meta'. These files can be downloaded from 'https://github.com/warmspringwinds/tf-image-segmentation' where please try to find 'Model Download Link'. Good Luck! @Harsh2040

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants