当前位置:   article > 正文

YOLOv5/v7训练结果results.csv绘制loss/mAP等曲线对比图_怎么根据yolov5的训练结果重新画图?

怎么根据yolov5的训练结果重新画图?

 1.实现代码

        可根据代码注释和自己的需求修改代码,实现自己的需求。

        python,复制粘贴改路径就能用。

  1. import os.path
  2. import pandas as pd
  3. import matplotlib.pyplot as plt
  4. # Function to clean column names
  5. def clean_column_names(df):
  6. df.columns = df.columns.str.strip()
  7. df.columns = df.columns.str.replace('\s+', '_', regex=True)
  8. # nonoresult.csv表示原始的结果图,csv文件在runs/train/exp中
  9. s_results = pd.read_csv(r"D:\python\projects\yolov5-7.0\runs\train-seg\exp28_5s\results.csv")
  10. C3CA_results = pd.read_csv(r"D:\python\projects\yolov5-7.0\runs\train-seg\exp-C3CA\results.csv")
  11. C3CBAM_results = pd.read_csv(r"D:\python\projects\yolov5-7.0\runs\train-seg\exp-C3CBAM\results.csv")
  12. C3ECA_results = pd.read_csv(r"D:\python\projects\yolov5-7.0\runs\train-seg\exp-C3ECA\results.csv")
  13. CA_results = pd.read_csv(r"D:\python\projects\yolov5-7.0\runs\train-seg\exp-CA\results.csv")
  14. CBAM_results = pd.read_csv(r"D:\python\projects\yolov5-7.0\runs\train-seg\exp-CBAM\results.csv")
  15. ECA_results = pd.read_csv(r"D:\python\projects\yolov5-7.0\runs\train-seg\exp-ECA\results.csv")
  16. # Clean column names
  17. clean_column_names(s_results)
  18. clean_column_names(C3CA_results)
  19. clean_column_names(C3CBAM_results)
  20. clean_column_names(C3ECA_results)
  21. clean_column_names(CA_results)
  22. clean_column_names(CBAM_results)
  23. clean_column_names(ECA_results)
  24. # Plot mAP@0.5 curves
  25. plt.figure()
  26. #中括号是results.csv表格中的列名称
  27. # lable属性为曲线名称,自己可以定义
  28. plt.plot(CA_results['metrics/mAP_0.5(B)'], label="YOLOv5s-seg")
  29. plt.plot(s_results['metrics/mAP_0.5(B)'], label="YOLOv5s-seg+CA")
  30. plt.plot(C3CA_results['metrics/mAP_0.5(B)'], label="YOLOv5s-seg+C3CA")
  31. plt.plot(C3CBAM_results['metrics/mAP_0.5(B)'], label="YOLOv5s-seg+C3CBAM")
  32. plt.plot(C3ECA_results['metrics/mAP_0.5(B)'], label="YOLOv5s-seg+C3ECA")
  33. plt.plot(CBAM_results['metrics/mAP_0.5(B)'], label="YOLOv5s-seg+CBAM")
  34. plt.plot(ECA_results['metrics/mAP_0.5(B)'], label="YOLOv5s-seg+ECA")
  35. #横坐标表示为
  36. plt.xlabel("Epoch")
  37. #纵坐标表示为
  38. plt.ylabel("mAP@0.5")
  39. plt.legend()
  40. #表格标题
  41. plt.title("mAP@0.5 Comparison")
  42. #保存路径
  43. plt.savefig(os.path.join(r'D:\python\projects\yolov5-7.0\runs\train-seg\1',
  44. "mAP_0.5_comparison.png"))

2.实现效果

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

闽ICP备14008679号