当前位置:   article > 正文

yolo训练之训练结果评估环节_ppyolo2的预测结果在哪

ppyolo2的预测结果在哪
在yolo中,怎么知道自己已经训练的怎么样了呢?自然是希望把训练过程中的loss等数据可视化一下,这篇文章中,我们主要就介绍一下这些。

1.记录终端信息到文件

首先在训练开始的时候需要把终端信息记录到文件,我这里使用的命令是| tee train_log.txt ,可参考:Linux中记录终端(Terminal)输出到文本文件 。我们会得到这样一个文本文件:
这里写图片描述

2. python数据处理

下面我们就可以用python对其进行处理了,这里我写了两个jupyter notebook,第一个可视化了loss,第二个可视化了iou。

#### **A.可视化loss**
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
  • 1
  • 2
  • 3
  • 4
result = pd.read_csv('trainlog.txt', skiprows=[x for x in range(60000) if x%10!=9] ,error_bad_lines=False, names=['loss', 'avg', 'rate', 'seconds', 'images'])
result.head()
  • 1
  • 2
lossavgratesecondsimages
01: 121.201286121.201286 avg0.000500 rate5.607964 seconds64 images
12: 116.259315120.707092 avg0.000500 rate5.027367 seconds128 images
23: 92.172997117.853683 avg0.000500 rate5.162279 seconds192 images
34: 85.307167114.599030 avg0.000500 rate4.845596 seconds256 images
45: 81.885292111.327652 avg0.000500 rate5.068791 seconds320 images
result['loss']=result['loss'].str.split(' ').str.get(1)
result['avg']=result['avg'].str.split(' ').str.get(1)
result['rate']=result['rate'].str.split(' ').str.get(1)
result['seconds']=result['seconds'].str.split(' ').str.get(1)
result['images']=result['images'].str.split(' ').str.get(1)
result.head()
result.tail()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
lossavgratesecondsimages
50060.9037840.9238440.0100004.661594320448
50070.8568210.9171420.0100004.695950320512
50080.9177660.9172040.0100004.740102320576
50090.8665800.9121420.0100004.713165320640
50101.0710780.9280350.0100004.728881320704
# print(result.head())
# print(result.tail())
# print(result.dtypes)
  • 1
  • 2
  • 3
result['loss']=pd.to_numeric(result['loss'])
result['avg']=pd.to_numeric(result['avg'])
result['rate']=pd.to_numeric(result['rate'])
result['seconds']=pd.to_numeric(result['seconds'])
result['images']=pd.to_numeric(result['images'])
result.dtypes
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
loss float64 avg float64 rate float64 seconds float64 images int64 dtype: object
result['loss'].plot()
  • 1
p=result['avg'].plot()
  • 1
![这里写图片描述](https://img-blog.csdn.net/20161229091306874?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTk5OTk5OTk5OTk5OWQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast) 图
result['avg'].values
  • 1
array([ 121.201286, 120.707092, 117.853683, …, 0.917204, 0.912142, 0.928035])
fig = plt.figure();
ax = fig.add_subplot(1, 1, 1)
ax.plot(result['avg'].values,label='avg_loss')
ax.legend(loc='best')
ax.set_title('The loss curves')
ax.set_xlabel('batches')
fig.savefig('avg_loss')
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
![这里写图片描述](https://img-blog.csdn.net/20161229091337399?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvTk5OTk5OTk5OTk5OWQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast) 图 #### **B.可视化IOU**
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
  • 1
  • 2
  • 3
  • 4
result = pd.read_csv('trainlog.txt', skiprows=[x for x in range(500000) if x%10==9 or x%10==0] ,error_bad_lines=False, names=['Detection Avg IOU', 'Pos Cat', 'All Cat', 'Pos Obj', 'Any Obj', 'count'])
result.head()
  • 1
  • 2
Detection Avg IOUPos CatAll CatPos ObjAny Objcount
0Detection Avg IOU: 0.061472Pos Cat: -0.054766All Cat: 0.160247Pos Obj: -0.081178Any Obj: -0.016451count: 16
1Detection Avg IOU: 0.083749Pos Cat: 0.272016All Cat: 0.223963Pos Obj: 0.130788Any Obj: -0.018666count: 14
2Detection Avg IOU: 0.105311Pos Cat: 0.178397All Cat: 0.069925Pos Obj: -0.062407Any Obj: -0.016685count: 17
3Detection Avg IOU: 0.056007Pos Cat: 0.142428All Cat: 0.043840Pos Obj: -0.197250Any Obj: -0.051494count: 15
4Detection Avg IOU: 0.085293Pos Cat: 0.108593All Cat: 0.033600Pos Obj: 0.020100Any Obj: -0.012297count: 15
result['Detection Avg IOU']=result['Detection Avg IOU'].str.split(': ').str.get(1)
result['Pos Cat']=result['Pos Cat'].str.split(': ').str.get(1)
result['All Cat']=result['All Cat'].str.split(': ').str.get(1)
result['Pos Obj']=result['Pos Obj'].str.split(': ').str.get(1)
result['Any Obj']=result['Any Obj'].str.split(': ').str.get(1)
result['count']=result['count'].str.split(': ').str.get(1)
result.head()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
Detection Avg IOUPos CatAll CatPos ObjAny Objcount
00.061472-0.0547660.160247-0.081178-0.01645116
10.0837490.2720160.2239630.130788-0.01866614
20.1053110.1783970.069925-0.062407-0.01668517
30.0560070.1424280.043840-0.197250-0.05149415
40.0852930.1085930.0336000.020100-0.01229715
result['Detection Avg IOU']=pd.to_numeric(result['Detection Avg IOU'])
result['Pos Cat']=pd.to_numeric(result['Pos Cat'])
result['All Cat']=pd.to_numeric(result['All Cat'])
result['Pos Obj']=pd.to_numeric(result['Pos Obj'])
result['Any Obj']=pd.to_numeric(result['Any Obj'])
result['count']=pd.to_numeric(result['count'])
result.dtypes
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
Detection Avg IOU    float64
Pos Cat              float64
All Cat              float64
Pos Obj              float64
Any Obj              float64
count                  int64
dtype: object
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
result['Detection Avg IOU'].plot()
  • 1
<matplotlib.axes._subplots.AxesSubplot at 0x7f4cdc6691d0>
  • 1

这里写图片描述

result['Pos Cat'].plot()
  • 1
<matplotlib.axes._subplots.AxesSubplot at 0x7f4cdc66c390>
  • 1

这里写图片描述

3. 看看结果至少还是符合趋势的,哈哈

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

闽ICP备14008679号