我执行以下代码:
import os
import numpy as np
def load_data(data_directory):
directories = [d for d in os.listdir(data_directory)
if os.path.isdir(os.path.join(data_directory, d))]
labels = []
images = []
for d in directories:
label_directory = os.path.join(data_directory,d)
file_names = [os.path.join(label_directory, f)
for f in os.listdir(label_directory)
if f.endswith(".ppm")]
for f in file_names:
images.append(skimage.data.imread(f))
labels.append(int(d))
return images, labels
ROOT_PATH = "/home/"
train_data_directory = os.path.join(ROOT_PATH, "BelgiumTSC_Training/Training")
test_data_directory = os.path.join(ROOT_PATH, "BelgiumTSC_Testing/Testing")
images, labels = load_data(train_data_directory)
# print the 'images' dimensions
print(np.array(images).ndim)
# print the number of 'images''s elements
print(np.array(images).size)
# print the first instance of 'images'
images[0]
我收到此错误:
Traceback (most recent call last):
File "loading_data.py", line 24, in <module>
images, labels = load_data(train_data_directory)
File "loading_data.py", line 16, in load_data
images.append(skimage.data.imread(f))
NameError: name 'skimage' is not defined
我点击了此链接,但没有成功: Import error No module named skimage
答案 0 :(得分:0)
经过多次搜索,我设法做了一些事情。我想问的是:在我的问题的链接中,该网站的下部区域中有一张带有标志的图片,旁边有“真相”和“预测”。他们代表什么?它们上的数字代表什么?这让我感到困惑,因为这不是我在其他培训中见过的,例如98%或90%的准确性。