WinError 3系统找不到指定的路径:加载图像文件时

问题描述 投票:0回答:1

我试图加载图像数据,但失败并出现错误:

 FileNotFoundError: [WinError 3] The system cannot find the path specified:

代码如下。

def load_data():
      datasets = ['seg_train/seg_train', 'seg_test/seg_test']
    size = (150,150)
    output = []
    for dataset in datasets:
        directory = 
            "D:/Hoin/Desktop/호준폴더/Python/Data/intel-image-classification/" + dataset
        images = []
        labels = []
        for folder in os.listdir(directory):
            curr_label = class_names_label[folder]
            for file in os.listdir(directory + "/" + folder):
                img_path = directory + "/" + folder + "/" + file
                curr_img = cv2.imread(img_path)
                curr_img = cv2.resize(curr_img, size)
                images.append(curr_img)
                labels.append(curr_label)
        images, labels = shuffle(images, labels)     ### Shuffle the data !!!
        images = np.array(images, dtype = 'float32') ### Our images
        labels = np.array(labels, dtype = 'int32')   ### From 0 to 
num_classes-1!

        output.append((images, labels))

    return output


(train_images, train_labels), (test_images, test_labels) = load_data()

然后我得到

Traceback (most recent call last):

  File "<ipython-input-59-bdc5f874dbf6>", line 1, in <module>
    (train_images, train_labels), (test_images, test_labels) = load_data()

  File "<ipython-input-58-23e2daec9c02>", line 15, in load_data
    for folder in os.listdir(directory):

  FileNotFoundError: [WinError 3] 지정된 경로를 찾을 수 없습니다: 
  'D:/Hoin/Desktop/호준폴더/Python/Data/intel-image-classification/seg_train/seg_train'  
(this means ''FileNotFoundError: [WinError 3] The system cannot find the path specified:') 

我不知道如何解决这个问题。我正在使用windows版本anaconda。谁可以帮我这个事?谢谢。

python file-not-found
1个回答
-1
投票

我在FileNotFoundError: [WinError 3] The system cannot find the path specified:烦人的错误上遇到了您的问题。

对我有用的是,我试图打败计算机并找到该路径,所以我在代码中发现了一个错误。

而且我也用双斜杠将“ //”放在链接上,就像"D://Hoin//Desktop//호준폴더//Python//Data//intel-image-classification//seg_train//seg_train"一样。

© www.soinside.com 2019 - 2024. All rights reserved.