IOError:[Errno 21] python目录出现问题

时间:2019-07-26 22:08:43

标签: python nvidia

我在通过Nvidia课程时遇到问题

我已经完成了DIGITS培训模型的一些工作。但是最后遇到了错误“ IOError:[Errno 2] No such file or directory:”的问题

MODEL_JOB_DIR = '/dli/data/digits/20180301-185638-e918'
!ls $MODEL_JOB_DIR

ARCHITECTURE = MODEL_JOB_DIR + '/' + 'deploy.prototxt'
WEIGHTS = MODEL_JOB_DIR + '/' + 'snapshot_iter_735.caffemodel'
print ("Filepath to Architecture = " + ARCHITECTURE)
print("Filepath to weights = "+ WEIGHTS)

import caffe
caffe.set_mode_gpu()

net = caffe.Classifier(ARCHITECTURE, WEIGHTS,  
                   channel_swap =(2, 1, 0), 
                   raw_scale=255) 

import matplotlib.pyplot as plt 
input_image= caffe.io.load_image('/dli/data/dogscats/train/cats/cat.10941.jpg')
plt.imshow(input_image)
plt.show()

DATA_JOB_DIR = '/dli/data/digits/20180301-185638-e918'
!ls $DATA_JOB_DIR

import cv2
input_image=cv2.resize(input_image, (256, 256), 0,0)
plt.imshow(input_image)
plt.show()

所有以前的代码都能很好地工作 但随后出现错误:

mean_image = caffe.io.load_image(DATA_JOB_DIR+'/mean.jpg')
ready_image = input_image-mean_image

IOErrorTraceback (most recent call last)
<ipython-input-29-16f709e9e2a7> in <module>()
----> 1 mean_image = caffe.io.load_image(DATA_JOB_DIR+'/mean.jpg')
  2 ready_image = input_image-mean_image

/usr/local/python/caffe/io.pyc in load_image(filename, color)
301         of size (H x W x 1) in grayscale.
302     """
--> 303     img = skimage.img_as_float(skimage.io.imread(filename, as_grey=not color)).astype(np.float32)
304     if img.ndim == 2:
305         img = img[:, :, np.newaxis]

/usr/local/lib/python2.7/dist-packages/skimage/io/_io.pyc in imread(fname, as_grey, plugin, flatten, **plugin_args)
 59 
 60     with file_or_url_context(fname) as fname:
---> 61         img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
 62 
 63     if not hasattr(img, 'ndim'):

/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.pyc in call_plugin(kind, *args, **kwargs)
209                                (plugin, kind))
210 
--> 211     return func(*args, **kwargs)
212 
213 

/usr/local/lib/python2.7/dist-packages/skimage/io/_plugins/pil_plugin.pyc in imread(fname, dtype, img_num, **kwargs)
 33     """
 34     if isinstance(fname, string_types):
---> 35         with open(fname, 'rb') as f:
 36             im = Image.open(f)
 37             return pil_to_ndarray(im, dtype=dtype, img_num=img_num)

IOError: [Errno 2] No such file or directory: '/dli/data/digits/20180301-185638-e918/mean.jpg'

因此,至少我必须正确指定目录,但没有目标。

0 个答案:

没有答案