Weird issue with running pretrained model with tensorflow - python

(tensorflow) C:\tensorflow\workspace\training_demo>python model_main_tf2.py --model_dir=C:/tensorflow/workspace/models/my_ssd_resnet50_v1_fpn --pipeline_config_path=C:/tensorflow/workspace/models/my_ssd_resnet50_v1_fpn/pipeline.config
From C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\object_detection\model_lib_v2.py:522: StrategyBase.experimental_distribute_datasets_from_function (from tensorflow.python.distribute.distribute_lib) is deprecated and will be removed in a future version.
Instructions for updating:
rename to distribute_datasets_from_function
Traceback (most recent call last):
File "model_main_tf2.py", line 113, in <module>
tf.compat.v1.app.run()
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\platform\app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\absl\app.py", line 300, in run
_run_main(main, args)
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\absl\app.py", line 251, in _run_main
sys.exit(main(argv))
File "model_main_tf2.py", line 104, in main
model_lib_v2.train_loop(
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\object_detection\model_lib_v2.py", line 522, in train_loop
train_input = strategy.experimental_distribute_datasets_from_function(
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\util\deprecation.py", line 340, in new_func
return func(*args, **kwargs)
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\distribute\distribute_lib.py", line 1143, in experimental_distribute_datasets_from_function
return self.distribute_datasets_from_function(dataset_fn, options)
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\distribute\distribute_lib.py", line 1134, in distribute_datasets_from_function
return self._extended._distribute_datasets_from_function( # pylint: disable=protected-access
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\distribute\mirrored_strategy.py", line 545, in _distribute_datasets_from_function
return input_lib.get_distributed_datasets_from_function(
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\distribute\input_lib.py", line 161, in get_distributed_datasets_from_function
return DistributedDatasetsFromFunction(dataset_fn, input_workers,
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\distribute\input_lib.py", line 1272, in __init__
_create_datasets_from_function_with_input_context(
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\distribute\input_lib.py", line 1936, in _create_datasets_from_function_with_input_context
dataset = dataset_fn(ctx)
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\object_detection\model_lib_v2.py", line 513, in train_dataset_fn
train_input = inputs.train_input(
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\object_detection\inputs.py", line 870, in train_input
dataset = INPUT_BUILDER_UTIL_MAP['dataset_build'](
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\object_detection\builders\dataset_builder.py", line 195, in build
decoder = decoder_builder.build(input_reader_config)
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\object_detection\builders\decoder_builder.py", line 52, in build
decoder = tf_example_decoder.TfExampleDecoder(
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\object_detection\data_decoders\tf_example_decoder.py", line 391, in __init__
_ClassTensorHandler(
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\object_detection\data_decoders\tf_example_decoder.py", line 88, in __init__
name_to_id = label_map_util.get_label_map_dict(
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\object_detection\utils\label_map_util.py", line 201, in get_label_map_dict
label_map = load_labelmap(label_map_path_or_proto)
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\object_detection\utils\label_map_util.py", line 168, in load_labelmap
label_map_string = fid.read()
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 117, in read
self._preread_check()
File "C:\Users\bigbootytx\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 79, in _preread_check
self._read_buf = _pywrap_file_io.BufferedInputStream(
tensorflow.python.framework.errors_impl.InvalidArgumentError: NewRandomAccessFile failed to Create/Open: C: ensorflow\workspacennotations\labelmap.pbtxt : The filename, directory name, or volume label syntax is incorrect.
; no protocol option
So im getting this weird issue where its changing the path of the file its looking for on its own.
C: ensorflow\workspacennotations\labelmap.pbtxt
should be
C:tensorflow\workspace\annotations\labelmap.pbtxt
Been stuck on this issue for quite a while now, tried several things including changing to forward slashes and stuff. Any idea what to do here? I followed this guide: https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html

\t in your path automatically replaces by tab. For prevent this on Windows, you need use double backslash (\\) as path delimiter: C:\\tensorflow\\...

Related

Getting following error when testing the trained python model

Please help me through this..
Traceback (most recent call last):
File "object_detection\legacy\train.py", line 186, in
tf.app.run()
File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\platform\app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages\absl\app.py", line 303, in run
_run_main(main, args)
File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages\absl\app.py", line 251, in _run_main
sys.exit(main(argv))
File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\util\deprecation.py", line 324, in new_func
return func(*args, **kwargs)
File "object_detection\legacy\train.py", line 110, in main
overwrite=True)
File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\lib\io\file_io.py", line 469, in copy
copy_v2(oldpath, newpath, overwrite)
File "C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages\tensorflow_core\python\lib\io\file_io.py", line 486, in copy_v2
compat.as_bytes(src), compat.as_bytes(dst), overwrite)
tensorflow.python.framework.errors_impl.NotFoundError: NewRandomAccessFile failed to Create/Open: : The system cannot find the path specified.
; No such process

facing coding error when want to train the model in google colab

the code I used was:
!python3 object_detection/model_main.py \
--pipeline_config_path=/gdrive/My\ Drive/object_detection/models/research/object_detection/samples/configs/ssd_mobilenet_v2_coco.config \
--model_dir=training/
and the errors I faced were:
**Traceback (most recent call last):
File "object_detection/model_main.py", line 109, in <module>
tf.app.run()
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 299, in run
_run_main(main, args)
File "/usr/local/lib/python3.6/dist-packages/absl/app.py", line 250, in _run_main
sys.exit(main(argv))
File "object_detection/model_main.py", line 71, in main
FLAGS.sample_1_of_n_eval_on_train_examples))
File "/content/drive/My Drive/object_detection/models/research/object_detection/model_lib.py", line 617, in create_estimator_and_inputs
pipeline_config_path, config_override=config_override)
File "/content/drive/My Drive/object_detection/models/research/object_detection/utils/config_util.py", line 103, in get_configs_from_pipeline_file
proto_str = f.read()
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/lib/io/file_io.py", line 122, in read
self._preread_check()
File "/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/lib/io/file_io.py", line 84, in _preread_check
compat.as_bytes(self.__name), 1024 * 512)
tensorflow.python.framework.errors_impl.NotFoundError:/gdrive/My Drive/object_detection/models/research/object_detection/samples/configs/ssd_mobilenet_v2_coco.config; No such file or directory
I have checked so many time that the path is already correct and connected, but don't know why still occur this error, please help!

Tensorflow model training

I am having problem with creating my own model for recognizing pets on images. I'm following Oxford pet recognizer walkthrough but i'm stuck with this error.
python object_detection/dataset_tools/create_pet_tf_record.py --data_dir=/home/cyber/Downloads/broji/annotations --output_dir=/home/cyber/Downloads/broji/output
Traceback (most recent call last):
File "object_detection/dataset_tools/create_pet_tf_record.py", line 318, in <module>
tf.app.run()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 124, in run
_sys.exit(main(argv))
File "object_detection/dataset_tools/create_pet_tf_record.py", line 271, in main
label_map_dict = label_map_util.get_label_map_dict(FLAGS.label_map_path)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/models/research/object_detection/utils/label_map_util.py", line 164, in get_label_map_dict
label_map = load_labelmap(label_map_path)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/models/research/object_detection/utils/label_map_util.py", line 133, in load_labelmap
label_map_string = fid.read()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/lib/io/file_io.py", line 119, in read
self._preread_check()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/lib/io/file_io.py", line 79, in _preread_check
compat.as_bytes(self.__name), 1024 * 512, status)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/errors_impl.py", line 473, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.NotFoundError: data/pet_label_map.pbtxt; No such file or directory

Tensorflow Object Detection Api Error model_main.py on Windows 10

I followed EdjeElectronics' guide on how to setup and run the TensorFlow Object Detection API, with Tensorflow-gpu 1.10 and Python 3.6.6.
When running the model_main.py with:
python model_main.py --logtostderr --model_dir=training/
--pipeline_config_path=C:/tensorflow1/models/research/object_detection/training/ssd_resnet50_v1_fpn_shared_box_predictor_640x640_coco14_sync.config
I get the following error:
(tensorflow1) C:\tensorflow1\models\research\object_detection>python model_main.py --logtostderr --model_dir=training/ --pipeline_config_path=C:/tensorflow1/models/research/object_detection/training/ssd_resnet50_v1_fpn_shared_box_predictor_640x640_coco14_sync.config
WARNING:tensorflow:Estimator's model_fn (<function create_model_fn.<locals>.model_fn at 0x00000213FF9CE158>) includes params argument, but params are not passed to Estimator.
Traceback (most recent call last):
File "model_main.py", line 101, in <module>
tf.app.run()
File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run
_sys.exit(main(argv))
File "model_main.py", line 97, in main
tf.estimator.train_and_evaluate(estimator, train_spec, eval_specs[0])
File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\estimator\training.py", line 451, in train_and_evaluate
return executor.run()
File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\estimator\training.py", line 590, in run
return self.run_local()
File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\estimator\training.py", line 691, in run_local
saving_listeners=saving_listeners)
File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\estimator\estimator.py", line 376, in train
loss = self._train_model(input_fn, hooks, saving_listeners)
File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\estimator\estimator.py", line 1145, in _train_model
return self._train_model_default(input_fn, hooks, saving_listeners)
File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\estimator\estimator.py", line 1167, in _train_model_default
input_fn, model_fn_lib.ModeKeys.TRAIN))
File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\estimator\estimator.py", line 1011, in _get_features_and_labels_from_input_fn
result = self._call_input_fn(input_fn, mode)
File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\estimator\estimator.py", line 1100, in _call_input_fn
return input_fn(**kwargs)
File "C:\tensorflow1\models\research\object_detection\inputs.py", line 408, in _train_input_fn
batch_size=params['batch_size'] if params else train_config.batch_size)
File "C:\tensorflow1\models\research\object_detection\builders\dataset_builder.py", line 123, in build
num_additional_channels=input_reader_config.num_additional_channels)
File "C:\tensorflow1\models\research\object_detection\data_decoders\tf_example_decoder.py", line 271, in __init__
use_display_name)
File "C:\tensorflow1\models\research\object_detection\utils\label_map_util.py", line 163, in get_label_map_dict
label_map = load_labelmap(label_map_path)
File "C:\tensorflow1\models\research\object_detection\utils\label_map_util.py", line 132, in load_labelmap
label_map_string = fid.read()
File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 125, in read
self._preread_check()
File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 85, in _preread_check
compat.as_bytes(self.__name), 1024 * 512, status)
File "C:\Users\nilsk\Anaconda3\envs\tensorflow1\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 519, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.NotFoundError: NewRandomAccessFile failed to Create/Open: C:/tensorflow1/models/research/object_detection/training/mscoco_label_map.pbtxt : Das System kann die angegebene Datei nicht finden.
; No such file or directory
I checked the paths in the .config at least a hundred times, mscoco_label_map.pbtxt definitely exists in this directory. Any ideas what might be wrong?
The issue is mostly with the pbtxt folder path format. If you are on windows, try backward double slash as following in the config file.
So instead of -
C:/tensorflow1/models/research/object_detection/training/mscoco_label_map.pbtxt
Use -
C:\tensorflow1\models\research\object_detection\training\mscoco_label_map.pbtxt
I solved it by simply recreating the .pbtxt. I still do not know what exactly was the problem, but now it works like a charm.

Does tf_debug truly support slim?

I have written the following code:
tf.contrib.slim.learning.train(
...
...
session_wrapper=tensorflow.python.debug.LocalCLIDebugWrapperSession,
...)
While running the code, it reported:
......
......
2018-02-14 01:03:25.229477: I tensorflow/core/debug/debug_graph_utils.cc:229] For debugging, tfdbg is changing the parallel_iterations attribute of the Enter/RefEnter node "lstm/lstm_1/while/Enter_2" on device "/job:localhost/replica:0/task:0/device:CPU:0" from 32 to 1. (This does not affect subsequent non-debug runs.)
Traceback (most recent call last):
File "train_getimageid_ngch.py", line 147, in <module>
tf.app.run()
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "train_getimageid_ngch.py", line 143, in main
saver=saver)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/contrib/slim/python/slim/learning.py", line 775, in train
sv.stop(threads, close_summary_writer=True)
File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
self.gen.throw(type, value, traceback)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/training/supervisor.py", line 964, in managed_session
self.stop(close_summary_writer=close_summary_writer)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/training/supervisor.py", line 792, in stop
stop_grace_period_secs=self._stop_grace_secs)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/training/coordinator.py", line 389, in join
six.reraise(*self._exc_info_to_raise)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/training/coordinator.py", line 296, in stop_on_exception
yield
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/training/coordinator.py", line 494, in run
self.run_loop()
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/training/supervisor.py", line 1068, in run_loop
global_step=self._sv.global_step)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1549, in save
global_step = training_util.global_step(sess, global_step)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/training/training_util.py", line 67, in global_step
return int(sess.run(global_step_tensor))
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/debug/wrappers/framework.py", line 543, in run
run_end_resp = self.on_run_end(run_end_req)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/debug/wrappers/local_cli_wrapper.py", line 321, in on_run_end
self._dump_root, partition_graphs=partition_graphs)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/debug/lib/debug_data.py", line 495, in __init__
self._load_all_device_dumps(partition_graphs, validate)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/debug/lib/debug_data.py", line 517, in _load_all_device_dumps
self._load_partition_graphs(partition_graphs, validate)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/debug/lib/debug_data.py", line 798, in _load_partition_graphs
self._validate_dump_with_graphs(debug_graph.device_name)
File "/home/ngaimanchow/tensorflow_virtualenv/local/lib/python2.7/site-packages/tensorflow/python/debug/lib/debug_data.py", line 843, in _validate_dump_with_graphs
"device %s." % (datum.node_name, device_name))
ValueError: Node name 'TFRecordReaderV2' is not found in partition graphs of device /job:localhost/replica:0/task:0/device:CPU:0.
Even it can start the tf debugger, when tried to print the value of a tensor, i.e. the pt command, it reported the error:
Error occured during handling of command: "print_tensor"
exceptions.KeyError /device:CPU:0
Is it possible for tf_debug to truly support slim? How can it be worked out? If not, is there any other way to debug or print the values of tensors when using tf.contrib.slim.learning.train?

Categories

Resources