山高水长
首页
  • 分类
  • 标签
  • 归档
友情链接
GitHub (opens new window)

山高水长

首页
  • 分类
  • 标签
  • 归档
友情链接
GitHub (opens new window)
  • mmdetection 结果可视化
  • mmdetection 训练出现 nan
  • mmdetection绘制PR曲线
  • 获取最高map的epoch
  • mmdetection报错汇总
  • mmdetection
Shanya
2022-05-12

获取最高map的epoch

# mmdetection 获取最高map的epoch

自动从训练结果中获取最高的mAP所对应的epoch。

import json
import os

'''
:param work_dir 训练结果目录
:return 最好的map对应的epoch路径
'''
def getBestEpoch(work_dir):
    global maxEpoch
    fileList = os.listdir(work_dir)
    for file in fileList:
        if os.path.splitext(file)[1] == '.json':
            print(file)
            json_file = open(os.path.join(work_dir, file))
            max_mAP = 0
            for line in json_file.readlines():
                json_data = json.loads(line)
                try:
                    if json_data['mode'] == 'val':
                        if float(json_data['bbox_mAP_50']) > max_mAP:
                            max_mAP = float(json_data['bbox_mAP_50'])
                            maxEpoch = json_data['epoch']
                except:
                    pass
    return os.path.join(work_dir, 'epoch_%d.pth' % maxEpoch)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
编辑 (opens new window)
#mmdetection
上次更新: 2022/09/30, 04:53:04
mmdetection绘制PR曲线
mmdetection报错汇总

← mmdetection绘制PR曲线 mmdetection报错汇总→

最近更新
01
FCOS
09-30
02
Python执行终端命令
09-13
03
Android Compose 权限请求
08-12
更多文章>
Theme by Vdoing | Copyright © 2020-2022 Shanya | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式