Skip to content
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

Merged
merged 9 commits into from
Jul 3, 2023

Conversation

Songyuanwei
Copy link
Collaborator

@Songyuanwei Songyuanwei commented Jun 29, 2023

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)

@Songyuanwei Songyuanwei changed the title modify logger, add logger_set level [WIP, don't merge] modify logger, add logger_set level Jun 30, 2023
from mindocr.utils.visualize import recover_image

logger = logging.getLogger("mindocr")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有些是 _logger, 有些是logger,保持一致会比较好

Copy link
Collaborator Author

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

Copy link
Collaborator

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等问题

Copy link
Collaborator Author

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"
)

Copy link
Collaborator

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会重复出现

Copy link
Collaborator Author

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调用会全局生效。

@SamitHuang SamitHuang merged commit f3cc9a5 into mindspore-lab:main Jul 3, 2023
from mindocr.utils.logger import Logger

_logger = Logger("mindocr")
_logger = logging.getLogger("mindocr")
Copy link
Collaborator

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
Copy link
Collaborator

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)

@Songyuanwei Songyuanwei deleted the branch_2 branch July 3, 2023 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants