当前位置:网站首页>Detectron2 save (according to maxap50) model during training_ best. PTH weight
Detectron2 save (according to maxap50) model during training_ best. PTH weight
2022-06-26 09:14:00 【G fruit】
Let me write it out front
The problem lies in GitHub Of detectron2 Of issues Put forward on , Someone solved ( As shown in the figure below )
Hint , Go to GitHub Upper issues Search for questions , Try to find 【closed】 Labeled , These are basically problems with solutions .
Just make a record here , For learning purposes only
Reference resources GitHub link :
Feature: a hook to automatically save the best model during training

Added package
from detectron2.engine import HookBase
Function function
class BestCheckpointer(HookBase):
def __init__(self):
super().__init__()
def after_step(self):
# No way to use **kwargs
##ONly do this analys when trainer.iter is divisle by checkpoint_epochs
curr_val = self.trainer.storage.latest().get('bbox/AP50', 0)
''' Minor changes have been made here '''
import math
if type(curr_val) != int:
curr_val = curr_val[0]
if math.isnan(curr_val):
curr_val = 0
try:
_ = self.trainer.storage.history('max_bbox/AP50')
except:
self.trainer.storage.put_scalar('max_bbox/AP50', curr_val)
max_val = self.trainer.storage.history('max_bbox/AP50')._data[-1][0]
#print(curr_val, max_val)
if curr_val > max_val:
print("\n%s > %s To save !!\n"%(curr_val,max_val))
self.trainer.storage.put_scalar('max_bbox/AP50', curr_val)
self.trainer.checkpointer.save("model_best")
#self.step(self.trainer.iter)
Usage method
os.makedirs(cfg.OUTPUT_DIR, exist_ok=True)
trainer = DefaultTrainer(cfg)
trainer.register_hooks([BestCheckpointer()])
trainer.resume_or_load(resume=False)
print(cfg)
trainer.train()
Realization effect


边栏推荐
- Self taught neural network series - 4 learning of neural network
- Phpcms V9 adds the reading amount field in the background, and the reading amount can be modified at will
- Nacos registry structure and the principle of massive service registration and concurrent read-write source code analysis
- Data warehouse (1) what is data warehouse and what are the characteristics of data warehouse
- PD快充磁吸移动电源方案
- Sqoop merge usage
- Machine learning (Part 1)
- 如何编译构建
- Principe et application du micro - ordinateur à puce unique - Aperçu
- Live review | smardaten lihongfei interprets the Research Report on China's low / no code industry: the wind direction has changed
猜你喜欢

编辑类型信息

《一周搞定数电》——组合逻辑电路

Uniapp uses uparse to parse the content of the background rich text editor and modify the uparse style

Yolov5 advanced zero environment rapid creation and testing
![[300+ continuous sharing of selected interview questions from large manufacturers] column on interview questions of big data operation and maintenance (I)](/img/cf/44b3983dd5d5f7b92d90d918215908.png)
[300+ continuous sharing of selected interview questions from large manufacturers] column on interview questions of big data operation and maintenance (I)

Nacos registry structure and the principle of massive service registration and concurrent read-write source code analysis

Mongodb分片环境搭建和验证(redis期末大作业)

Yolov5 advanced 4 train your own data set

Nacos注册表结构和海量服务注册与并发读写原理 源码分析

Fast construction of neural network
随机推荐
行为树 文件说明
Mongodb分片环境搭建和验证(redis期末大作业)
Lagrange multiplier method
小程序首页加载之前加载其他相关资源或配置(小程序的promise应用)
[300+ continuous sharing of selected interview questions from large manufacturers] column on interview questions of big data operation and maintenance (I)
Runtimeerror: object has no attribute NMS error record when using detectron2
如何利用最少的钱,快速打开淘宝流量入口?
Router bridging settings
How to handle the small program tabbar that does not support parameter transfer
编辑类型信息
Nacos registry structure and the principle of massive service registration and concurrent read-write source code analysis
Tensor
简析ROS计算图级
docker安装redis
phpcms v9去掉phpsso模块
MySQL cannot be found in the service (not uninstalled)
Sqoop merge usage
常用电路设计
《一周搞定模电》—功率放大器
uniapp用uParse实现解析后台的富文本编辑器的内容及修改uParse样式