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

#561 Feature/sg 193 extend output formator

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

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