Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

#643 PPYolo-E

Merged
Ghost merged 1 commits into Deci-AI:master from deci-ai:feature/SG-344-PP-Yolo-E-Training-Replicate-Recipe
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  1. import os
  2. import logging
  3. import logging.config
  4. from typing import Union
  5. from super_gradients.common.environment.env_variables import env_variables
  6. from super_gradients.common.auto_logging.auto_logger import AutoLoggerConfig
  7. def get_logger(logger_name: str, log_level: Union[str, None] = None) -> logging.Logger:
  8. AutoLoggerConfig.get_instance()
  9. logger: logging.Logger = logging.getLogger(logger_name)
  10. if log_level is not None:
  11. logger.setLevel(log_level)
  12. if int(env_variables.LOCAL_RANK) > 0:
  13. mute_current_process()
  14. return logger
  15. class ILogger:
  16. """
  17. Provides logging capabilities to the derived class.
  18. """
  19. def __init__(self, logger_name: str = None):
  20. logger_name = logger_name if logger_name else str(self.__module__)
  21. self._logger: logging.Logger = get_logger(logger_name)
  22. def mute_current_process():
  23. """Mute prints, warnings and all logs except ERRORS. This is meant when running multiple processes."""
  24. # Ignore warnings
  25. import warnings
  26. warnings.filterwarnings("ignore")
  27. # Ignore prints
  28. import sys
  29. sys.stdout = open(os.devnull, "w")
  30. # Only show ERRORS
  31. process_loggers = [logging.getLogger(name) for name in logging.root.manager.loggerDict]
  32. for logger in process_loggers:
  33. logger.setLevel(logging.ERROR)
Discard
Tip!

Press p or to see the previous file or, n or to see the next file