1. 程式人生 > >根據索引檔案劃分資料集

根據索引檔案劃分資料集

索引檔案.txt:

根據索引檔案中的視訊編號劃分訓練集,測試集,驗證集

g = open('./ACRN/TACoS/TACoS_val_videos.txt','r')
label=g.readlines()
print(label)
len(label)

 

path = r'.\videos\video'
x = path+"\\"+label[0].strip('\n').split(',')[0]
x

import shutil
path = r'.\videos\video'
path_new = r'.\videos\val_data'
for i in range(len(label)):
    name = label[i].strip('\n').split(',')[0]
    print(name)
    print(path+'\\'+name)
    name_new = label[i].strip('\n').split(',')[0].split('.')[0]
    #num = label[i].strip('\n').split(',')[1]
    root = path_new + '\\'+ name_new + '.avi'
    print(root)
    shutil.copyfile(path+'\\'+name, root)

按照索引檔案的編號,將指定資料檔案複製到已經建好的資料夾中