赞
踩
可根据代码注释和自己的需求修改代码,实现自己的需求。
python,复制粘贴改路径就能用。
- import os.path
-
- import pandas as pd
- import matplotlib.pyplot as plt
-
-
- # Function to clean column names
- def clean_column_names(df):
- df.columns = df.columns.str.strip()
- df.columns = df.columns.str.replace('\s+', '_', regex=True)
-
-
- # nonoresult.csv表示原始的结果图,csv文件在runs/train/exp中
- s_results = pd.read_csv(r"D:\python\projects\yolov5-7.0\runs\train-seg\exp28_5s\results.csv")
- C3CA_results = pd.read_csv(r"D:\python\projects\yolov5-7.0\runs\train-seg\exp-C3CA\results.csv")
- C3CBAM_results = pd.read_csv(r"D:\python\projects\yolov5-7.0\runs\train-seg\exp-C3CBAM\results.csv")
- C3ECA_results = pd.read_csv(r"D:\python\projects\yolov5-7.0\runs\train-seg\exp-C3ECA\results.csv")
- CA_results = pd.read_csv(r"D:\python\projects\yolov5-7.0\runs\train-seg\exp-CA\results.csv")
- CBAM_results = pd.read_csv(r"D:\python\projects\yolov5-7.0\runs\train-seg\exp-CBAM\results.csv")
- ECA_results = pd.read_csv(r"D:\python\projects\yolov5-7.0\runs\train-seg\exp-ECA\results.csv")
-
- # Clean column names
- clean_column_names(s_results)
- clean_column_names(C3CA_results)
- clean_column_names(C3CBAM_results)
- clean_column_names(C3ECA_results)
- clean_column_names(CA_results)
- clean_column_names(CBAM_results)
- clean_column_names(ECA_results)
-
- # Plot mAP@0.5 curves
- plt.figure()
- #中括号是results.csv表格中的列名称
- # lable属性为曲线名称,自己可以定义
- plt.plot(CA_results['metrics/mAP_0.5(B)'], label="YOLOv5s-seg")
- plt.plot(s_results['metrics/mAP_0.5(B)'], label="YOLOv5s-seg+CA")
- plt.plot(C3CA_results['metrics/mAP_0.5(B)'], label="YOLOv5s-seg+C3CA")
- plt.plot(C3CBAM_results['metrics/mAP_0.5(B)'], label="YOLOv5s-seg+C3CBAM")
- plt.plot(C3ECA_results['metrics/mAP_0.5(B)'], label="YOLOv5s-seg+C3ECA")
- plt.plot(CBAM_results['metrics/mAP_0.5(B)'], label="YOLOv5s-seg+CBAM")
- plt.plot(ECA_results['metrics/mAP_0.5(B)'], label="YOLOv5s-seg+ECA")
-
- #横坐标表示为
- plt.xlabel("Epoch")
- #纵坐标表示为
- plt.ylabel("mAP@0.5")
- plt.legend()
- #表格标题
- plt.title("mAP@0.5 Comparison")
- #保存路径
- plt.savefig(os.path.join(r'D:\python\projects\yolov5-7.0\runs\train-seg\1',
- "mAP_0.5_comparison.png"))
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。