Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tensorflow TFRecordWriter:访问被拒绝_Tensorflow - Fatal编程技术网

Tensorflow TFRecordWriter:访问被拒绝

Tensorflow TFRecordWriter:访问被拒绝,tensorflow,Tensorflow,我正在尝试为我的数据创建一个TFRecord文件,为此我正在使用TFRecordWriter,但它无法写入目录,并引发以下错误: Stacktrace: FLAGS.output_path: E:\ml\output Traceback (most recent call last): File "conversion_script_for_converting_dataset_to_TFRECORD_format.py", line 126, in <module> tf.app

我正在尝试为我的数据创建一个
TFRecord
文件,为此我正在使用
TFRecordWriter
,但它无法写入目录,并引发以下错误:

Stacktrace:

FLAGS.output_path: E:\ml\output
Traceback (most recent call last):
 File "conversion_script_for_converting_dataset_to_TFRECORD_format.py", line 126, in <module>
tf.app.run()
File "C:\Python\Python35\lib\site-packages\tensorflow\python\platform\app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "conversion_script_for_converting_dataset_to_TFRECORD_format.py", line 107, in main
writer = tf.python_io.TFRecordWriter(FLAGS.output_path)
File "C:\Python\Python35\lib\site-packages\tensorflow\python\lib\io\tf_record.py", line 106, in __init__
compat.as_bytes(path), compat.as_bytes(compression_type), status)
File "C:\Python\Python35\lib\contextlib.py", line 66, in __exit__
next(self.gen)
File "C:\Python\Python35\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.UnknownError: Failed to create a NewWriteableFile: E:\ml\output : Access is denied.
; Input/output error
import tensorflow as tf
import os
import io
from PIL import Image
from object_detection.utils import dataset_util

flags = tf.app.flags
flags.DEFINE_string('output_path', 'E:\\ml\\output', '')
FLAGS = flags.FLAGS

def main(_):
  print('test')
  print("FLAGS.output_path: {}".format(FLAGS.output_path))
  writer = tf.python_io.TFRecordWriter(FLAGS.output_path)

  # TODO(user): Write code to read in your dataset to examples variable
  PATH_TO_TEST_IMAGES_DIR = 'E:\ml\dataset_in_TFRECORD_format'
  image_files = [ os.path.join(PATH_TO_TEST_IMAGES_DIR, 'img{}'.format(i)) for i in range(0, 2) ]

  for image_file in image_files:
    image_path = image_file + '.jpg'
    image_metadata_path = image_file + '_manmet.txt'
    print('Image path: {}'.format(image_path))
    print('Image metadata path: {}'.format(image_metadata_path))
    print('\n')
    tf_example = create_tf_example(image_path, image_metadata_path)
    writer.write(tf_example.SerializeToString())

    writer.close()


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

我在Git bash、Windows PowerShell、Windows PowerShell(Admin)中尝试过它,但得到了相同的错误。

路径也必须包含文件名

flags.DEFINE_string('output_path', 'E:\\ml\\output\\filename.record', '')

您应该在路径中定义文件名,代码如下:

flags.DEFINE_string('output_path', 'E:\\ml\\output', '')