import pandas as pd import os import shutil source_path = '/home/shanwei-luo/teamdata/anomaly_detection_active_learning/data0422/unlabel_11_12/' dist_path_01 = '/home/shanwei-luo/teamdata/anomaly_detection_active_learning/data0422/smd12_11_12_hard_score_01/train/' dist_path_02 = '/home/shanwei-luo/teamdata/anomaly_detection_active_learning/data0422/smd12_11_12_hard_score_02/train/' infer_data=pd.read_csv('./test_unlabel_11_12.csv') print(infer_data.shape) infer_data.info() infer_data.describe() infer_data.head() print(infer_data['score']) print(infer_data['Image_Name']) infer_data = infer_data.sort_values('score',ascending=False) select_01 = [] select_02 = [] for index, row in infer_data.iterrows(): #print(row['Image_Name'], row['score']) if len(select_01) < 2750: select_01.append(row['Image_Name']) if row['score']<0.85 and len(select_02)<2750: select_02.append(row['Image_Name']) print(len(select_01)) print(len(select_02)) count_img = 0 count_label = 0 for file in select_01: shutil.copy(source_path+'images/'+file, dist_path_01+'images/'+file) count_img += 1 if os.path.exists(source_path+'labels/'+file.replace(".jpg",".txt")): shutil.copy(source_path+'labels/'+file.replace(".jpg",".txt"), dist_path_01+'labels/'+file.replace(".jpg",".txt")) count_label += 1 print(count_img, count_label) count_img = 0 count_label = 0 for file in select_02: shutil.copy(source_path+'images/'+file, dist_path_02+'images/'+file) count_img += 1 if os.path.exists(source_path+'labels/'+file.replace(".jpg",".txt")): shutil.copy(source_path+'labels/'+file.replace(".jpg",".txt"), dist_path_02+'labels/'+file.replace(".jpg",".txt")) count_label += 1 print(count_img, count_label) '''print(len(infer_data['feature'][0])) feat = infer_data['feature'][0].split(",") print(len(feat)) print(feat[0])'''