with open("./RML2016.10a_dict.dat", 'rb') as xd1: Xd = cPickle.load(xd1) # ,encoding='latin1' for each_mod in mod_del: for each_snr in snr_del: tmp = "'%s',%d" %(each_mod, each_snr) tmp = eval(tmp) del Xd[tmp] cPickle.dump(Xd, file("test.dat", "wb"))
if __name__ == '__main__': picture_list = os.listdir(src_path) count = len(picture_list) random.shuffle(picture_list) with open('./train.txt', 'w') as f: for i, picture_name in enumerate(picture_list): for index, name in enumerate(name_list): if name in picture_name: if i != count-1: f.write(picture_name+' '+str(index)) f.write('\n') else: f.write(picture_name + ' ' + str(index)) f.close() print('write success!')
defcreate_txt(picture_list): for i, picture_name in enumerate(picture_list): for index, name in enumerate(name_list): if name in picture_name: f.write(picture_name + ' ' + str(index)) f.write('\n') else: continue
if __name__ == '__main__': folder_list = os.listdir(src_path) with open('./test.txt', 'w') as f: for folder in folder_list: folder = src_path +'/'+ folder picture_list = os.listdir(folder) random.shuffle(picture_list) # count += len(picture_list) create_txt(picture_list) f.close() print('write success!')
if __name__ == '__main__': dir_list = os.listdir(src_path) for i in dir_list: p = os.path.join(src_path, i) os.system('cp %s/* %s/val' % (p, src_path_))