-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
modify logger, add logger_set level #467
Conversation
from mindocr.utils.visualize import recover_image | ||
|
||
logger = logging.getLogger("mindocr") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有些是 _logger, 有些是logger,保持一致会比较好
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
主脚本用的是logger,例如train.py, eval.py等,其余调用的脚本用的_logger
tools/modelarts_adapter/modelarts.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不建议在modelarts.py 使用logger,因为modelart 会比 mindocr 先import,然后在modelart装必须的package等等再import mindocr。如果在这里预先import mindocr会出module missing等问题
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里没有调用mindocr,之前调用的现在去掉了
@@ -152,7 +146,7 @@ def on_train_step_end(self, run_context): | |||
f"loss: {loss:.6f}, " + lr_str + f"per step time: {per_step_time:.3f} ms, fps: {fps:.2f} img/s" | |||
) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里要加个if main_rank 保护,否则distributed training message会重复出现
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我试过了,分布式之后0卡打印,在logger.py文件设置了,只有0卡打印,然后main.py调用会全局生效。
from mindocr.utils.logger import Logger | ||
|
||
_logger = Logger("mindocr") | ||
_logger = logging.getLogger("mindocr") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_logger = logging.getLogger(__name__)
?
@@ -33,30 +36,26 @@ def main(cfg): | |||
parallel_mode="data_parallel", | |||
gradients_mean=True, | |||
) | |||
set_logger( | |||
name="mindocr", output_dir=cfg.train.ckpt_save_dir or "./", log_fn=f"log_eval_{rank_id}.txt", rank=rank_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of logger here (mindocr
) is different form initialized above (mindocr.eval
)
Thank you for your contribution to the MindOCR repo.
Before submitting this PR, please make sure:
Motivation
(Write your motivation for proposed changes here.)
Test Plan
(How should this PR be tested? Do you require special setup to run the test or repro the fixed bug?)
Related Issues and PRs
#429
(Is this PR part of a group of changes? Link the other relevant PRs and Issues here. Use https://help.github.com/en/articles/closing-issues-using-keywords for help on GitHub syntax)