Tensorflow Windows访问文件夹被拒绝:"NewRandomAccessFile创建/打开失败:访问被拒绝. ;输入/输出错误" [英] Tensorflow Windows Accessing Folders Denied:"NewRandomAccessFile failed to Create/Open: Access is denied. ; Input/output error"

查看:987
本文介绍了Tensorflow Windows访问文件夹被拒绝:"NewRandomAccessFile创建/打开失败:访问被拒绝. ;输入/输出错误"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近安装了Windows版Tensorflow.我正在尝试一个基本教程,在该教程中,我需要访问包含图像子文件夹的文件夹.

I recently installed Tensorflow for Windows. I am attempting a basic tutorial in which I need to access a folder containing sub-folders of images.

我无法访问图像文件夹,因为访问被拒绝".在Anaconda 4.2提示符和Pycharm中,以及使用基本的Python 3.5发行版,都会发生这种情况.

I am not able to access the folder of images because "access is denied". This happens both in the Anaconda 4.2 prompt and in Pycharm, and using the basic Python 3.5 distribution.

我已为所有涉及的内容赋予管理员特权,并且我今天重新安装了所有软件,因此所有软件均已更新为最新版本.

I have given administrator privileges to everything involved and I reinstalled all of the software today so it is all updated to latest versions.

任何想法或帮助将不胜感激!

Any thoughts or help would be greatly appreciated!

# change this as you see fit
image_path = 'C:/moles'

# Read in the image_data
image_data = tf.gfile.FastGFile(image_path, 'rb').read()

# Loads label file, strips off carriage return
label_lines = [line.rstrip() for line
               in tf.gfile.GFile("/tf_files/retrained_labels.txt")]

# Unpersists graph from file
with tf.gfile.FastGFile("/tf_files/retrained_graph.pb", 'rb') as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())
    _ = tf.import_graph_def(graph_def, name='')

with tf.Session() as sess:
    # Feed the image_data as input to the graph and get first prediction
    softmax_tensor = sess.graph.get_tensor_by_name('final_result:0')

    predictions = sess.run(softmax_tensor, \
                           {'DecodeJpeg/contents:0': image_data})

    # Sort to show labels of first prediction in order of confidence
    top_k = predictions[0].argsort()[-len(predictions[0]):][::-1]

    for node_id in top_k:
        human_string = label_lines[node_id]
        score = predictions[0][node_id]
        print('%s (score = %.5f)' % (human_string, score))

"C:\Program Files\Anaconda3\python.exe" C:/Users/Ryan/Desktop/tfupdate/tf.py
    Traceback (most recent call last):

      File "C:/Users/Ryan/Desktop/tfupdate/tf.py", line 7, in <module>
        image_data = tf.gfile.FastGFile(image_path, 'rb').read()

      File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 106, in read
        self._preread_check()

      File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 73, in _preread_check
        compat.as_bytes(self.__name), 1024 * 512, status)

      File "C:\Program Files\Anaconda3\lib\contextlib.py", line 66, in __exit__
        next(self.gen)

      File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 469, in raise_exception_on_not_ok_status
        pywrap_tensorflow.TF_GetCode(status))

    tensorflow.python.framework.errors_impl.UnknownError: NewRandomAccessFile failed to Create/Open: C:/moles : Access is denied.
    ; Input/output error

    Process finished with exit code 1

推荐答案

正确地将路径/tf_files/retrained_labels.txt赋予retrained_labels.txt路径,并对/tf_files/retrained_graph.pb

Give the path correctly /tf_files/retrained_labels.txt to your retrained_labels.txt path and same changes for /tf_files/retrained_graph.pb

这篇关于Tensorflow Windows访问文件夹被拒绝:"NewRandomAccessFile创建/打开失败:访问被拒绝. ;输入/输出错误"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆