用途 | 数据集 |
---|---|
train(训练) | 训练集 |
validation/test(验证) | 验证集 |
test/evaluate(测试/评估) | 测试集 |
现在测试集和验证集分的都不太清楚,每个人叫法不同,验证集通常可以从测试集中选出一小部分。
用python划分数据集:
import os
path = 'o_rgb/'
list_folders = os.listdir(path)
#print(str(list_folders[1]))
num_folders = len(list_folders)
#print(num_folders)
item_count =0
train_files = open('train.txt','w')
val_files = open('val.txt','w')
test_files = open('test.txt','w')
for f in range(num_folders):
folder_name = str(list_folders[f])
path_folder = path + folder_name + '/'
#print(path_folder)
images = os.listdir(path_folder)
#print(images[0][:-4])
path_images = [(path_folder+img[:-4]+'\n') for img in images]
#print(path_images)
if f<30:
test_files.writelines(path_images)
elif f < 55:
val_files.writelines(path_images)
else:
train_files.writelines(path_images)
train_files.close()
val_files.close()
test_files.close()
import os
train_files = open('train.txt','w')
test_files = open('test.txt','w')
path = 'rgb/'
images = os.listdir(path)
out_images = [(img[:-4]+'\n') for img in images]
train_images = []
test_images = []
for i in range(len(out_images)):
if i % 10 == 0:
test_images.append(out_images[i])
else:
train_images.append(out_images[i])
test_files.writelines(test_images)
train_files.writelines(train_images)
train_files.close()
test_files.close()