plot_result.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import warnings
  2. warnings.filterwarnings('ignore')
  3. import os
  4. import pandas as pd
  5. import numpy as np
  6. import matplotlib.pylab as plt
  7. pwd = os.getcwd()
  8. names = []
  9. plt.figure(figsize=(10, 10))
  10. plt.subplot(2, 2, 1)
  11. for i in names:
  12. data = pd.read_csv(f'runs/train/{i}/results.csv')
  13. data[' metrics/precision(B)'] = data[' metrics/precision(B)'].astype(np.float32).replace(np.inf, np.nan)
  14. data[' metrics/precision(B)'] = data[' metrics/precision(B)'].fillna(data[' metrics/precision(B)'].interpolate())
  15. plt.plot(data[' metrics/precision(B)'], label=i)
  16. plt.xlabel('epoch')
  17. plt.title('precision')
  18. plt.legend()
  19. plt.subplot(2, 2, 2)
  20. for i in names:
  21. data = pd.read_csv(f'runs/train/{i}/results.csv')
  22. data[' metrics/recall(B)'] = data[' metrics/recall(B)'].astype(np.float32).replace(np.inf, np.nan)
  23. data[' metrics/recall(B)'] = data[' metrics/recall(B)'].fillna(data[' metrics/recall(B)'].interpolate())
  24. plt.plot(data[' metrics/recall(B)'], label=i)
  25. plt.xlabel('epoch')
  26. plt.title('recall')
  27. plt.legend()
  28. plt.subplot(2, 2, 3)
  29. for i in names:
  30. data = pd.read_csv(f'runs/train/{i}/results.csv')
  31. data[' metrics/mAP50(B)'] = data[' metrics/mAP50(B)'].astype(np.float32).replace(np.inf, np.nan)
  32. data[' metrics/mAP50(B)'] = data[' metrics/mAP50(B)'].fillna(data[' metrics/mAP50(B)'].interpolate())
  33. plt.plot(data[' metrics/mAP50(B)'], label=i)
  34. plt.xlabel('epoch')
  35. plt.title('mAP_0.5')
  36. plt.legend()
  37. plt.subplot(2, 2, 4)
  38. for i in names:
  39. data = pd.read_csv(f'runs/train/{i}/results.csv')
  40. data[' metrics/mAP50-95(B)'] = data[' metrics/mAP50-95(B)'].astype(np.float32).replace(np.inf, np.nan)
  41. data[' metrics/mAP50-95(B)'] = data[' metrics/mAP50-95(B)'].fillna(data[' metrics/mAP50-95(B)'].interpolate())
  42. plt.plot(data[' metrics/mAP50-95(B)'], label=i)
  43. plt.xlabel('epoch')
  44. plt.title('mAP_0.5:0.95')
  45. plt.legend()
  46. plt.tight_layout()
  47. plt.savefig('metrice_curve.png')
  48. print(f'metrice_curve.png save in {pwd}/metrice_curve.png')
  49. plt.figure(figsize=(15, 10))
  50. plt.subplot(2, 3, 1)
  51. for i in names:
  52. data = pd.read_csv(f'runs/train/{i}/results.csv')
  53. data[' train/box_loss'] = data[' train/box_loss'].astype(np.float32).replace(np.inf, np.nan)
  54. data[' train/box_loss'] = data[' train/box_loss'].fillna(data[' train/box_loss'].interpolate())
  55. plt.plot(data[' train/box_loss'], label=i)
  56. plt.xlabel('epoch')
  57. plt.title('train/box_loss')
  58. plt.legend()
  59. plt.subplot(2, 3, 2)
  60. for i in names:
  61. data = pd.read_csv(f'runs/train/{i}/results.csv')
  62. data[' train/dfl_loss'] = data[' train/dfl_loss'].astype(np.float32).replace(np.inf, np.nan)
  63. data[' train/dfl_loss'] = data[' train/dfl_loss'].fillna(data[' train/dfl_loss'].interpolate())
  64. plt.plot(data[' train/dfl_loss'], label=i)
  65. plt.xlabel('epoch')
  66. plt.title('train/dfl_loss')
  67. plt.legend()
  68. plt.subplot(2, 3, 3)
  69. for i in names:
  70. data = pd.read_csv(f'runs/train/{i}/results.csv')
  71. data[' train/cls_loss'] = data[' train/cls_loss'].astype(np.float32).replace(np.inf, np.nan)
  72. data[' train/cls_loss'] = data[' train/cls_loss'].fillna(data[' train/cls_loss'].interpolate())
  73. plt.plot(data[' train/cls_loss'], label=i)
  74. plt.xlabel('epoch')
  75. plt.title('train/cls_loss')
  76. plt.legend()
  77. plt.subplot(2, 3, 4)
  78. for i in names:
  79. data = pd.read_csv(f'runs/train/{i}/results.csv')
  80. data[' val/box_loss'] = data[' val/box_loss'].astype(np.float32).replace(np.inf, np.nan)
  81. data[' val/box_loss'] = data[' val/box_loss'].fillna(data[' val/box_loss'].interpolate())
  82. plt.plot(data[' val/box_loss'], label=i)
  83. plt.xlabel('epoch')
  84. plt.title('val/box_loss')
  85. plt.legend()
  86. plt.subplot(2, 3, 5)
  87. for i in names:
  88. data = pd.read_csv(f'runs/train/{i}/results.csv')
  89. data[' val/dfl_loss'] = data[' val/dfl_loss'].astype(np.float32).replace(np.inf, np.nan)
  90. data[' val/dfl_loss'] = data[' val/dfl_loss'].fillna(data[' val/dfl_loss'].interpolate())
  91. plt.plot(data[' val/dfl_loss'], label=i)
  92. plt.xlabel('epoch')
  93. plt.title('val/dfl_loss')
  94. plt.legend()
  95. plt.subplot(2, 3, 6)
  96. for i in names:
  97. data = pd.read_csv(f'runs/train/{i}/results.csv')
  98. data[' val/cls_loss'] = data[' val/cls_loss'].astype(np.float32).replace(np.inf, np.nan)
  99. data[' val/cls_loss'] = data[' val/cls_loss'].fillna(data[' val/cls_loss'].interpolate())
  100. plt.plot(data[' val/cls_loss'], label=i)
  101. plt.xlabel('epoch')
  102. plt.title('val/cls_loss')
  103. plt.legend()
  104. plt.tight_layout()
  105. plt.savefig('loss_curve.png')
  106. print(f'loss_curve.png save in {pwd}/loss_curve.png')