首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Tensorflow窗口访问文件夹被拒绝:“NewRandomAccessFile无法创建/打开:访问被拒绝。;输入/输出错误”

Tensorflow窗口访问文件夹被拒绝:“NewRandomAccessFile无法创建/打开:访问被拒绝。;输入/输出错误”
EN

Stack Overflow用户
提问于 2016-12-13 16:09:11
回答 2查看 16.5K关注 0票数 15

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

我无法访问图像文件夹,因为“访问被拒绝”。这在Anaconda 4.2提示符和Pycharm中都会发生,并使用基本的Python3.5发行版。

我已经为所有涉及到的软件提供了管理员权限,并且我今天重新安装了所有软件,所以它们都更新到了最新版本。

如有任何想法或帮助,我们将不胜感激!

代码语言:javascript
运行
复制
# 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
EN

回答 2

Stack Overflow用户

发布于 2017-01-26 14:13:01

正确指定retrained_labels.txt路径的/tf_files/retrained_labels.txt路径,并对/tf_files/retrained_graph.pb进行相同的更改

票数 5
EN

Stack Overflow用户

发布于 2018-09-25 03:05:48

我在使用tensorflow时遇到了类似的问题--除了以管理员身份运行命令提示符之外,我还被拒绝了权限,所以我是如何解决的--

  1. 确保python安装适用于PC上的所有用户如果不是,请尝试将python安装的路径添加到PC的全局环境变量,而不是用户变量
  2. 以管理员身份运行命令提示符,输入command-

net用户管理员口令“/active:yes”

将该密码替换为要提供给admin用户的密码

重新启动菜单中的

  1. ,切换用户为管理员,然后尝试使用python classify.py命令

应该行得通,让我知道它是否有用

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41116270

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档