99from mmdet .utils .util_ymir import write_ymir_training_result
1010from torch .nn .modules .batchnorm import _BatchNorm
1111from ymir_exc import monitor
12- from ymir_exc .util import YmirStage , get_ymir_process
12+ from ymir_exc .util import YmirStage , get_merged_config , write_ymir_monitor_process
1313
1414
1515def _calc_dynamic_intervals (start_interval , dynamic_interval_list ):
@@ -28,6 +28,7 @@ class EvalHook(BaseEvalHook):
2828
2929 def __init__ (self , * args , dynamic_intervals = None , ** kwargs ):
3030 super (EvalHook , self ).__init__ (* args , ** kwargs )
31+ self .ymir_cfg = get_merged_config ()
3132
3233 self .use_dynamic_intervals = dynamic_intervals is not None
3334 if self .use_dynamic_intervals :
@@ -51,9 +52,7 @@ def after_train_epoch(self, runner):
5152 if self .by_epoch :
5253 monitor_interval = max (1 , runner .max_epochs // 1000 )
5354 if runner .epoch % monitor_interval == 0 :
54- percent = get_ymir_process (
55- stage = YmirStage .TASK , p = runner .epoch / runner .max_epochs )
56- monitor .write_monitor_logger (percent = percent )
55+ write_ymir_monitor_process (self .ymir_cfg , task = 'training' , naive_stage_percent = runner .epoch / runner .max_epochs , stage = YmirStage .TASK )
5756 super ().after_train_epoch (runner )
5857
5958 def before_train_iter (self , runner ):
@@ -64,9 +63,7 @@ def after_train_iter(self, runner):
6463 if not self .by_epoch :
6564 monitor_interval = max (1 , runner .max_iters // 1000 )
6665 if runner .iter % monitor_interval == 0 :
67- percent = get_ymir_process (
68- stage = YmirStage .TASK , p = runner .iter / runner .max_iters )
69- monitor .write_monitor_logger (percent = percent )
66+ write_ymir_monitor_process (self .ymir_cfg , task = 'training' , naive_stage_percent = runner .ite / runner .max_iters , stage = YmirStage .TASK )
7067 super ().after_train_iter (runner )
7168
7269 def _do_evaluate (self , runner ):
@@ -98,6 +95,7 @@ class DistEvalHook(BaseDistEvalHook):
9895
9996 def __init__ (self , * args , dynamic_intervals = None , ** kwargs ):
10097 super (DistEvalHook , self ).__init__ (* args , ** kwargs )
98+ self .ymir_cfg = get_merged_config ()
10199
102100 self .use_dynamic_intervals = dynamic_intervals is not None
103101 if self .use_dynamic_intervals :
@@ -121,9 +119,7 @@ def after_train_epoch(self, runner):
121119 if self .by_epoch and runner .rank == 0 :
122120 monitor_interval = max (1 , runner .max_epochs // 1000 )
123121 if runner .epoch % monitor_interval == 0 :
124- percent = get_ymir_process (
125- stage = YmirStage .TASK , p = runner .epoch / runner .max_epochs )
126- monitor .write_monitor_logger (percent = percent )
122+ write_ymir_monitor_process (self .ymir_cfg , task = 'training' , naive_stage_percent = runner .epoch / runner .max_epochs , stage = YmirStage .TASK )
127123 super ().after_train_epoch (runner )
128124
129125 def before_train_iter (self , runner ):
@@ -134,9 +130,7 @@ def after_train_iter(self, runner):
134130 if not self .by_epoch and runner .rank == 0 :
135131 monitor_interval = max (1 , runner .max_iters // 1000 )
136132 if runner .iter % monitor_interval == 0 :
137- percent = get_ymir_process (
138- stage = YmirStage .TASK , p = runner .iter / runner .max_iters )
139- monitor .write_monitor_logger (percent = percent )
133+ write_ymir_monitor_process (self .ymir_cfg , task = 'training' , naive_stage_percent = runner .iter / runner .max_iters , stage = YmirStage .TASK )
140134 super ().after_train_iter (runner )
141135
142136 def _do_evaluate (self , runner ):
0 commit comments