当前位置:   article > 正文

批量提取yolo训练后的csv,方便对比个模型之间的优劣_已经训练好的csv

已经训练好的csv
  1. import os
  2. import csv
  3. # 文件夹路径
  4. folder_path = r"E:\yolov5-master\runs\train"
  5. # 创建结果csv文件并写入表头
  6. result_file = "epresult.csv"
  7. with open(result_file, mode='w', newline='') as file:
  8. writer = csv.writer(file)
  9. writer.writerow(['Folder Name', 'Line Count', 'metrics/mAP_0.5', 'metrics/mAP_0.5:0.95'])
  10. # 遍历文件夹
  11. for folder_name in os.listdir(folder_path):
  12. folder_dir = os.path.join(folder_path, folder_name)
  13. # 寻找.csv文件
  14. for file_name in os.listdir(folder_dir):
  15. if file_name.endswith(".csv"):
  16. csv_file = os.path.join(folder_dir, file_name)
  17. # 打开并读取CSV文件
  18. with open(csv_file, mode='r') as csv_data:
  19. csv_reader = csv.reader(csv_data)
  20. data = list(csv_reader)
  21. # 获取行数
  22. line_count = len(data) - 1
  23. # 提取指定列的最后一行数据
  24. mAP_0_5 = data[-1][data[0].index(' metrics/mAP_0.5')]
  25. mAP_0_5_0_95 = data[-1][data[0].index('metrics/mAP_0.5:0.95')]
  26. # 将提取的数据写入结果csv文件
  27. writer.writerow([folder_name, line_count, mAP_0_5, mAP_0_5_0_95])

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/129787
推荐阅读
相关标签
  

闽ICP备14008679号