models icon indicating copy to clipboard operation
models copied to clipboard

tensorflow.python.framework.errors_impl.NotFoundError: =; No such file or directory

Open JPQuadrado opened this issue 8 years ago • 36 comments

#help

JPQuadrado avatar Mar 27 '18 02:03 JPQuadrado

Traceback (most recent call last): File "train.py", line 167, in tf.app.run() File "/home/joao/Python_T/TensorF/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 126, in run _sys.exit(main(argv)) File "train.py", line 92, in main FLAGS.pipeline_config_path) File "/home/joao/Python_T/TensorF/models/research/object_detection/utils/config_util.py", line 87, in get_configs_from_pipeline_file proto_str = f.read() File "/home/joao/Python_T/TensorF/lib/python3.5/site-packages/tensorflow/python/lib/io/file_io.py", line 120, in read self._preread_check() File "/home/joao/Python_T/TensorF/lib/python3.5/site-packages/tensorflow/python/lib/io/file_io.py", line 80, in _preread_check compat.as_bytes(self.__name), 1024 * 512, status) File "/home/joao/Python_T/TensorF/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py", line 516, in exit c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.NotFoundError: =; No such file or directory

JPQuadrado avatar Mar 27 '18 02:03 JPQuadrado

check your path in your config file. maybe some path will be set wrong

alifejon avatar Mar 27 '18 06:03 alifejon

You should input this command again.Pay attention to this 'space'

surfound avatar Mar 29 '18 01:03 surfound

amrita@amrita-VirtualBox:~/Downloads/Object-Detection$ python3 generate_tfrecord.py --csv_input=data/train_labels.csv --output_path=data/train.record Traceback (most recent call last): File "generate_tfrecord.py", line 99, in tf.app.run() File "/home/amrita/.local/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 126, in run _sys.exit(main(argv)) File "generate_tfrecord.py", line 90, in main tf_example = create_tf_example(group, path) File "generate_tfrecord.py", line 45, in create_tf_example encoded_jpg = fid.read() File "/home/amrita/.local/lib/python3.6/site-packages/tensorflow/python/lib/io/file_io.py", line 120, in read self._preread_check() File "/home/amrita/.local/lib/python3.6/site-packages/tensorflow/python/lib/io/file_io.py", line 80, in _preread_check compat.as_bytes(self.__name), 1024 * 512, status) File "/home/amrita/.local/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 516, in exit c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.NotFoundError: /home/amrita/Downloads/Object-Detection/images/100.jpg; No such file or directory

I am facing this error in ubuntu. Thanks if anyone can help

Amri95 avatar Apr 19 '18 03:04 Amri95

Traceback (most recent call last): File "train.py", line 167, in tf.app.run() File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "train.py", line 107, in main overwrite=True) File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/lib/io/file_io.py", line 385, in copy compat.as_bytes(oldpath), compat.as_bytes(newpath), overwrite, status) File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 473, in exit c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.NotFoundError: ; No such file or directory

Stuck here not able to move further.. lease help me with this

symbolnotdefined avatar Jul 01 '18 10:07 symbolnotdefined

Getting a same error when used sentdex code of generate_tfrecord.py.

Please help

robinnarsinghranabhat avatar Jul 05 '18 18:07 robinnarsinghranabhat

I am also facing same issue, while running the script. Below is my error please help.

Traceback (most recent call last): File "F:/Object_detection/generate_tfrecord.py", line 98, in tf.app.run() File "C:\Users\Harjeet\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\platform\app.py", line 126, in run _sys.exit(main(argv)) File "F:/Object_detection/generate_tfrecord.py", line 89, in main tf_example = create_tf_example(group, path) File "F:/Object_detection/generate_tfrecord.py", line 44, in create_tf_example encoded_jpg = fid.read() File "C:\Users\Harjeet\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 120, in read self._preread_check() File "C:\Users\Harjeet\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 80, in _preread_check compat.as_bytes(self.__name), 1024 * 512, status) File "C:\Users\Harjeet\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 516, in exit c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.NotFoundError: NewRandomAccessFile failed to Create/Open: F:\Object_detection\images\pic3.jpeg : The system cannot find the file specified. ; No such file or directory

Technebby avatar Jul 10 '18 16:07 Technebby

I am also facing same issue, while running the script. Below is my error please help.

Traceback (most recent call last): File "object_detection/generate_tfrecord.py", line 99, in 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/generate_tfrecord.py", line 85, in main writer = tf.python_io.TFRecordWriter(FLAGS.output_path) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/lib/io/tf_record.py", line 106, in init compat.as_bytes(path), compat.as_bytes(compression_type), 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/train.record; No such file or directory

tamizharasank avatar Jul 18 '18 09:07 tamizharasank

I was facing the same issue, but found a way to resolve it. If you replace "FLAGS.output_path" (in writer = tf.python_io.TFRecordWriter(FLAGS.output_path) in generate_tfrecord.py) with the full path to where you want your output to be (i.e. F:/Object_detection/train.record for the train/ect) it resolved it for me.

VoyantDeclaire avatar Jul 20 '18 14:07 VoyantDeclaire

Getting same error. still cant find a solution

shanmugavel28 avatar Aug 11 '18 07:08 shanmugavel28

@VoyantDeclaire still no changes

iamSushi avatar Sep 15 '18 20:09 iamSushi

(base) C:\Projects\models\research\object_detection>python generate_tfrecord.py --csv_input=images\train_labels.csv --image_dir=images\train --output_path=train.record

and error...

  File "generate_tfrecord.py", line 104, in <module>
    tf.app.run()
  File "C:\Users\iamSushi\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\platform\app.py", line 125, in run
    _sys.exit(main(argv))
  File "generate_tfrecord.py", line 95, in main
    tf_example = create_tf_example(group, path)
  File "generate_tfrecord.py", line 50, in create_tf_example
    encoded_jpg = fid.read()
  File "C:\Users\iamSushi\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\lib\io\file_io.py", line 125, in read
    self._preread_check()
  File "C:\Users\iamSushi\AppData\Roaming\Python\Python36\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\iamSushi\AppData\Roaming\Python\Python36\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:\Projects\models\research\object_detection\images\train\1 : The system cannot find the file specified.
; No such file or directory```

![capture](https://user-images.githubusercontent.com/15758902/45590246-2e0a5800-b967-11e8-9ef9-36c8e64ceb5e.PNG)


```from __future__ import division
from __future__ import print_function
from __future__ import absolute_import

import os
import io
import pandas as pd
import tensorflow as tf

from PIL import Image
from object_detection.utils import dataset_util
from collections import namedtuple, OrderedDict

flags = tf.app.flags
flags.DEFINE_string('csv_input', '', 'Path to the CSV input')
flags.DEFINE_string('image_dir', '', 'Path to the image directory')
flags.DEFINE_string('output_path', '', 'Path to output TFRecord')
FLAGS = flags.FLAGS


# TO-DO replace this with label map
def class_text_to_int(row_label):
    if row_label == 'taxi':
        return 1
    elif row_label == 'motorcycle':
        return 2
    elif row_label == 'jeepney':
        return 3
    else:
        None


def split(df, group):
    data = namedtuple('data', ['filename', 'object'])
    gb = df.groupby(group)
    return [data(filename, gb.get_group(x)) for filename, x in zip(gb.groups.keys(), gb.groups)]


def create_tf_example(group, path):
    with tf.gfile.GFile(os.path.join(path, '{}'.format(group.filename)), 'rb') as fid:
        encoded_jpg = fid.read()
    encoded_jpg_io = io.BytesIO(encoded_jpg)
    image = Image.open(encoded_jpg_io)
    width, height = image.size

    filename = group.filename.encode('utf8')
    image_format = b'jpg'
    xmins = []
    xmaxs = []
    ymins = []
    ymaxs = []
    classes_text = []
    classes = []

    for index, row in group.object.iterrows():
        xmins.append(row['xmin'] / width)
        xmaxs.append(row['xmax'] / width)
        ymins.append(row['ymin'] / height)
        ymaxs.append(row['ymax'] / height)
        classes_text.append(row['class'].encode('utf8'))
        classes.append(class_text_to_int(row['class']))

    tf_example = tf.train.Example(features=tf.train.Features(feature={
        'image/height': dataset_util.int64_feature(height),
        'image/width': dataset_util.int64_feature(width),
        'image/filename': dataset_util.bytes_feature(filename),
        'image/source_id': dataset_util.bytes_feature(filename),
        'image/encoded': dataset_util.bytes_feature(encoded_jpg),
        'image/format': dataset_util.bytes_feature(image_format),
        'image/object/bbox/xmin': dataset_util.float_list_feature(xmins),
        'image/object/bbox/xmax': dataset_util.float_list_feature(xmaxs),
        'image/object/bbox/ymin': dataset_util.float_list_feature(ymins),
        'image/object/bbox/ymax': dataset_util.float_list_feature(ymaxs),
        'image/object/class/text': dataset_util.bytes_list_feature(classes_text),
        'image/object/class/label': dataset_util.int64_list_feature(classes),
    }))
    return tf_example


def main(_):
    writer = tf.python_io.TFRecordWriter(FLAGS.output_path)
    path = os.path.join(os.getcwd(), FLAGS.image_dir)
    examples = pd.read_csv(FLAGS.csv_input)
    grouped = split(examples, 'filename')
    for group in grouped:
        tf_example = create_tf_example(group, path)
        writer.write(tf_example.SerializeToString())

    writer.close()
    output_path = os.path.join(os.getcwd(), FLAGS.output_path)
    print('Successfully created the TFRecords: {}'.format(output_path))


if __name__ == '__main__':
    tf.app.run()```

this code is from https://www.youtube.com/watch?v=Rgpfk6eYxJA&feature=share

iamSushi avatar Sep 15 '18 20:09 iamSushi

i have given up it.

2018-09-16 4:17 GMT+08:00, James Sinadjan [email protected]:

generate_tfrecord.py --csv_input=images\train_labels.csv
--image_dir=images\train --output_path=train.record```

and error...

```Traceback (most recent call last):
  File "generate_tfrecord.py", line 104, in <module>
    tf.app.run()
  File
"C:\Users\iamSushi\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\platform\app.py",
line 125, in run
    _sys.exit(main(argv))
  File "generate_tfrecord.py", line 95, in main
    tf_example = create_tf_example(group, path)
  File "generate_tfrecord.py", line 50, in create_tf_example
    encoded_jpg = fid.read()
  File
"C:\Users\iamSushi\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\lib\io\file_io.py",
line 125, in read
    self._preread_check()
  File
"C:\Users\iamSushi\AppData\Roaming\Python\Python36\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\iamSushi\AppData\Roaming\Python\Python36\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:\Projects\models\research\object_detection\images\train\1 : The system
cannot find the file specified.
; No such file or directory```

![capture](https://user-images.githubusercontent.com/15758902/45590246-2e0a5800-b967-11e8-9ef9-36c8e64ceb5e.PNG)


--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
https://github.com/tensorflow/models/issues/3762#issuecomment-421627952

surfound avatar Sep 28 '18 07:09 surfound

Solution is simple: Open configuration file of your model.Lets say you are using SSD model and your configuration file is "ssd_mobilenet_v1_pets.config". Then open that file search "label_map_path" variable which gives path to pbtx file. Set exact path for it. Then it will work like charm.

tanajikamble13 avatar Nov 22 '18 13:11 tanajikamble13

The problem for me with "No such file or directory" for images that I know exist and are readable was that I had bounding boxes for objects that were too small (less than 33 px). I ran sizeChecker.py with the --move flag and it found/moved the problematic images. generate_tfrecord.py worked like a charm after that.

spomroy avatar Jan 25 '19 11:01 spomroy

i solved the problem you change the file location extensions and comment out all the Flags being used like below

flags = tf.app.flags
"""flags.DEFINE_string('csv_input', '', 'data\train_labels.csv')
flags.DEFINE_string('output_path', '', 'data')
flags.DEFINE_string('image_dir', '', 'images\train')
FLAGS = flags.FLAGS
"""

so below is how you change the train and test location to your directories the one containing the folders images and data

def main(_):
    writer = tf.python_io.TFRecordWriter('data/test.record') #FLAGS.output_path
    path = os.path.join('images/test') #FLAGS.image_dir
    examples = pd.read_csv('data/test_labels.csv') # FLAGS.csv_input
    grouped = split(examples, 'filename')
    for group in grouped:
        tf_example = create_tf_example(group, path)
        writer.write(tf_example.SerializeToString())
    writer.close()
    output_path = os.path.join(os.getcwd(), 'data/test.record') #FLAGS.output_path
    print('Successfully created the TFRecords:'.format(output_path))

TechCorp07 avatar Feb 25 '19 04:02 TechCorp07

Capture i have this issue,permission denid issue can you help me slove this error.

DILEEPKUMA avatar Mar 16 '19 08:03 DILEEPKUMA

Capture i have this issue,permission denid issue can you help me slove this error.

This is permission error. Just write sudo before the command. It will be resolved. Example: sudo python3 train.py

ronak34 avatar May 01 '19 12:05 ronak34

For Sentdex:

You need to run "python generate_tfrecord.py --csv_input=data/test_labels.csv --output_path=data/test.record --image_dir=test" with "--image_dir=test". (this was not necessary by the time he recorded the video)

Additionally, you need to add "images/" to a path in the "create_tf_example()" function: with tf.gfile.GFile("images/" + os.path.join(path, '{}'.format(group.filename)), 'rb') as fid: encoded_jpg = fid.read()

Donges-Niklas avatar May 06 '19 04:05 Donges-Niklas

Problem for me was that I used: python object_detection/legacy/train.py --logtostderr --train_dir=training/ --pipeline_config_path=ssd_mobilenet_v1_pets.config

Instead of: python object_detection/legacy/train.py --logtostderr --train_dir=/training --pipeline_config_path=ssd_mobilenet_v1_pets.config

That one slash in train_dir. Make sure you set your config path accordingly as well.

kareembelgharbi avatar Jun 18 '19 19:06 kareembelgharbi