for root, dirs, files in os.walk(query_path, topdown=True): for name in files: ifnot name[-3:]=='jpg': continue ID = name.split('_') src_path = query_path + '/' + name dst_path = query_save_path + '/' + ID[0] ifnot os.path.isdir(dst_path): os.mkdir(dst_path) copyfile(src_path, dst_path + '/' + name)
#----------------------------------------- #multi-query query_path = download_path + '/gt_bbox' # for dukemtmc-reid, we do not need multi-query if os.path.isdir(query_path): query_save_path = download_path + '/pytorch/multi-query' ifnot os.path.isdir(query_save_path): os.mkdir(query_save_path)
for root, dirs, files in os.walk(query_path, topdown=True): for name in files: ifnot name[-3:]=='jpg': continue ID = name.split('_') src_path = query_path + '/' + name dst_path = query_save_path + '/' + ID[0] ifnot os.path.isdir(dst_path): os.mkdir(dst_path) copyfile(src_path, dst_path + '/' + name)
for root, dirs, files in os.walk(train_path, topdown=True): for name in files: ifnot name[-3:]=='jpg': continue ID = name.split('_') src_path = train_path + '/' + name dst_path = train_save_path + '/' + ID[0] ifnot os.path.isdir(dst_path): os.mkdir(dst_path) dst_path = val_save_path + '/' + ID[0] #first image is used as val image os.mkdir(dst_path) copyfile(src_path, dst_path + '/' + name)