我最近安裝了Tensorflow for Windows。我正在嘗試一個基本教程,其中需要訪問包含圖像子文件夾的文件夾。Tensorflow Windows訪問文件夾被拒絕:「NewRandomAccessFile無法創建/打開:訪問被拒絕;;輸入/輸出錯誤」
我無法訪問圖像文件夾,因爲「訪問被拒絕」。這發生在Anaconda 4.2提示符和Pycharm中,並且使用基本的Python 3.5發行版。
我已授予所有涉及的管理員權限,並且今天我重新安裝了所有軟件,因此它全部更新爲最新版本。
任何想法或幫助將不勝感激!
# 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 回溯(最近通話最後一個):
文件「C :/Users/Ryan/Desktop/tfupdate/tf.py 「第7行,在 = IMAGE_DATA tf.gfile.FastGFile(IMAGE_PATH, 'RB')讀()
文件。」 C:\ Program Files文件\ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ lib \ io \ file_io.py「,第106行,在讀 self._preread_check()
_preread_check中的第73行文件「C:\ Program Files \ Anaconda3 \ lib \ site-packages \ tensorflow \ python \ lib \ io \ file_io.py」 compat.as_bytes(self .__ name),1024 * 512,狀態)
文件 「C:\ Program Files文件\ Anaconda3 \ LIB \ contextlib.py」 66行,在出口 未來(self.gen)
文件「C:\ Program Files文件\ Anaconda3 \ LIB \站點包\ tensorflow \ python的\框架\ errors_impl.py」,線路469,在raise_exception_on_not_ok_status pywrap_tensorflow.TF_GetCode(狀態))
tensorflow.p ython.framework.errors_impl.UnknownError:NewRandomAccessFile無法創建/打開:C:/ moles:訪問被拒絕。 ;輸入/輸出錯誤
過程與退出代碼完成1
是'C:/ moles'圖像文件的名稱?錯誤的原因似乎是'C:/ moles'是一個文件夾,但是您正在嘗試像文件一樣讀取它。 – mrry