Search code examples
pythontensorflowtfrecord

give the right path in terminal to import tfrecord file


I am following the guide of deeplab to train the provided model on the dataset cityscapes.

With the provided bash file (as the Step.1 in the guide), I converted the raw data to the form of tfrecord.

While in the Step.2 of the guide, I am requested to give the path to the dataset as a terminal flag "dataset_dir":

python deeplab/train.py \ # ... some unrelevant flags
    --train_logdir=${PATH_TO_TRAIN_DIR} \
    --dataset_dir=${PATH_TO_DATASET}

The guide's hint for the path is "${PATH_TO_DATASET} is the directory in which the Cityscapes dataset resides."

However,

  • the path to the upper folder of tfrecord

    • (/home/workspace/models-master/research/deeplab/datasets/cityscapes/tfrecord/)
  • the path to a single tfrecord

    • (/home/workspace/models-master/research/deeplab/datasets/cityscapes/tfrecord/train-00000-of-00010.tfrecord)

returned the following error, saying that such file can't be found:

Traceback (most recent call last):
  File "deeplab/train.py", line 520, in <module>
    tf.app.run()
  File "/home/zwang/.local/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "/home/zwang/.local/lib/python3.6/site-packages/absl/app.py", line 299, in run
    _run_main(main, args)
  File "/home/zwang/.local/lib/python3.6/site-packages/absl/app.py", line 250, in _run_main
    sys.exit(main(argv))
  File "deeplab/train.py", line 470, in main
    dataset.get_one_shot_iterator(), dataset.num_of_classes,
  File "/home/zwang/workspace/models-master/research/deeplab/datasets/data_generator.py", line 320, in get_one_shot_iterator
    files = self._get_all_files()
  File "/home/zwang/workspace/models-master/research/deeplab/datasets/data_generator.py", line 347, in _get_all_files
    return tf.gfile.Glob(file_pattern)
  File "/home/zwang/.local/lib/python3.6/site-packages/tensorflow/python/lib/io/file_io.py", line 363, in get_matching_files
    return get_matching_files_v2(filename)
  File "/home/zwang/.local/lib/python3.6/site-packages/tensorflow/python/lib/io/file_io.py", line 384, in get_matching_files_v2
    compat.as_bytes(pattern))
tensorflow.python.framework.errors_impl.NotFoundError: /home/workspace/models-master/research/deeplab/datasets/cityscapes/.; No such file or directory

How to give the right path in order to import the tfrecord file? Am I right about the path, or the error may be somewhere else?


Solution

  • It turns out to be missing my user name in that address of home:

    /home/USERNAME/workspace

    instead of

    /home/workspace