tensorflow.python.framework.errors_impl.NotFoundError: =; No such file or directory
#help
Traceback (most recent call last):
File "train.py", line 167, in
check your path in your config file. maybe some path will be set wrong
You should input this command again.Pay attention to this 'space'
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
I am facing this error in ubuntu. Thanks if anyone can help
Traceback (most recent call last):
File "train.py", line 167, in
Stuck here not able to move further.. lease help me with this
Getting a same error when used sentdex code of generate_tfrecord.py.
Please help
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
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
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.
Getting same error. still cant find a solution
@VoyantDeclaire still no changes
(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```

```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
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```  -- 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
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.
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.
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))
i have this issue,permission denid issue can you help me slove this error.
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
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()
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.