You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

select_hard_CI.py 1.9 kB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import pandas as pd
  2. import os
  3. import shutil
  4. source_path = '/home/shanwei-luo/teamdata/anomaly_detection_active_learning/data0422/unlabel_11_12/'
  5. dist_path_01 = '/home/shanwei-luo/teamdata/anomaly_detection_active_learning/data0422/smd12_11_12_hard_score_01/train/'
  6. dist_path_02 = '/home/shanwei-luo/teamdata/anomaly_detection_active_learning/data0422/smd12_11_12_hard_score_02/train/'
  7. infer_data=pd.read_csv('./test_unlabel_11_12.csv')
  8. print(infer_data.shape)
  9. infer_data.info()
  10. infer_data.describe()
  11. infer_data.head()
  12. print(infer_data['score'])
  13. print(infer_data['Image_Name'])
  14. infer_data = infer_data.sort_values('score',ascending=False)
  15. select_01 = []
  16. select_02 = []
  17. for index, row in infer_data.iterrows():
  18. #print(row['Image_Name'], row['score'])
  19. if len(select_01) < 2750:
  20. select_01.append(row['Image_Name'])
  21. if row['score']<0.85 and len(select_02)<2750:
  22. select_02.append(row['Image_Name'])
  23. print(len(select_01))
  24. print(len(select_02))
  25. count_img = 0
  26. count_label = 0
  27. for file in select_01:
  28. shutil.copy(source_path+'images/'+file, dist_path_01+'images/'+file)
  29. count_img += 1
  30. if os.path.exists(source_path+'labels/'+file.replace(".jpg",".txt")):
  31. shutil.copy(source_path+'labels/'+file.replace(".jpg",".txt"), dist_path_01+'labels/'+file.replace(".jpg",".txt"))
  32. count_label += 1
  33. print(count_img, count_label)
  34. count_img = 0
  35. count_label = 0
  36. for file in select_02:
  37. shutil.copy(source_path+'images/'+file, dist_path_02+'images/'+file)
  38. count_img += 1
  39. if os.path.exists(source_path+'labels/'+file.replace(".jpg",".txt")):
  40. shutil.copy(source_path+'labels/'+file.replace(".jpg",".txt"), dist_path_02+'labels/'+file.replace(".jpg",".txt"))
  41. count_label += 1
  42. print(count_img, count_label)
  43. '''print(len(infer_data['feature'][0]))
  44. feat = infer_data['feature'][0].split(",")
  45. print(len(feat))
  46. print(feat[0])'''

No Description

Contributors (3)