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

#609 Ci fix

Merged
Ghost merged 1 commits into Deci-AI:master from deci-ai:bugfix/infra-000_ci
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
  1. from abc import abstractmethod, ABC
  2. from typing import Union, Any
  3. import numpy as np
  4. from PIL import Image
  5. import torch
  6. class AbstractSGLogger(ABC):
  7. """
  8. A SGLogger handles all outputs of the training process.
  9. Every generated file, log, metrics value, image or other artifacts produced by the trainer will be processed and saved.
  10. Inheriting SGLogger can be used in order to integrate experiment management framework, special storage setting, a specific logging library etc.
  11. Important: The BaseSGLogger class (inheriting from SGLogger) is used by the trainer by default. When defining your own SGLogger you will
  12. override all default output functionality. No files will saved to disk and no data will be collected.
  13. Make sure you either implement this functionality or use SGLoggers.Compose([BaseSGLogger(...), YourSGLogger(...)]) to build on top of it.
  14. """
  15. @abstractmethod
  16. def add(self, tag: str, obj: Any, global_step: int = None):
  17. """
  18. A generic function for adding any type of data to the SGLogger. By default, this function is not called by the Trainer, BaseSGLogger
  19. does nothing with this type of data. But if you need to pass a data type which is not supported by any of the following abstract methods, use this
  20. method.
  21. """
  22. raise NotImplementedError
  23. @abstractmethod
  24. def add_config(self, tag: str, config: dict):
  25. """
  26. Add the configuration (settings and hyperparameters) to the SGLoggers.
  27. Typically, this function will add the configuration dictionary to logs,
  28. write it to tensorboard, send it to an experiment management framework ect.
  29. :param tag: Data identifier
  30. :param config: a dictionary of the experiment config
  31. """
  32. raise NotImplementedError
  33. @abstractmethod
  34. def add_scalar(self, tag: str, scalar_value: float, global_step: int = None):
  35. """
  36. Add scalar data to SGLogger.
  37. Typically, this function will add scalar to tensorboard or other experiment management framework.
  38. :param tag: Data identifier
  39. :param scalar_value: Value to save
  40. :param global_step: Global step value to record
  41. """
  42. raise NotImplementedError
  43. @abstractmethod
  44. def add_scalars(self, tag_scalar_dict: dict, global_step: int = None):
  45. """
  46. Adds multiple scalar data to SGLogger.
  47. Typically, this function will add scalars to tensorboard or other experiment management framework.
  48. :param tag_scalar_dict: a dictionary {tag(str): value(float)} of the scalars.
  49. :param global_step: Global step value to record
  50. """
  51. raise NotImplementedError
  52. @abstractmethod
  53. def add_image(self, tag: str, image: Union[torch.Tensor, np.array, Image.Image], data_format: str = 'CHW', global_step: int = None):
  54. """
  55. Add a single image to SGLogger.
  56. Typically, this function will add an image to tensorboard, save it to disk or add it to experiment management framework.
  57. :param tag: Data identifier
  58. :param image: an image to be added. The values should lie in [0, 255] for type uint8 or [0, 1] for type float.
  59. :param data_format: Image data format specification of the form CHW, HWC, HW, WH, etc.
  60. :param global_step: Global step value to record
  61. """
  62. raise NotImplementedError
  63. @abstractmethod
  64. def add_images(self, tag: str, images: Union[torch.Tensor, np.array], data_format='NCHW', global_step: int = None):
  65. """
  66. Add multiple images to SGLogger.
  67. Typically, this function will add images to tensorboard, save them to disk or add them to experiment management framework.
  68. :param tag: Data identifier
  69. :param images: images to be added. The values should lie in [0, 255] for type uint8 or [0, 1] for type float.
  70. :param data_format: Image data format specification of the form NCHW, NHWC, NHW, NWH, etc.
  71. :param global_step: Global step value to record
  72. """
  73. raise NotImplementedError
  74. @abstractmethod
  75. def add_histogram(self, tag: str, values: Union[torch.Tensor, np.array], bins: Union[str, np.array, list, int] = 'auto', global_step: int = None):
  76. """
  77. Add a histogram to SGLogger.
  78. Typically, this function will add a histogram to tensorboard or add it to experiment management framework.
  79. :param tag: Data identifier
  80. :param values: Values to build histogram
  81. :param bins: This determines how the bins are made.
  82. If bins is an int, it defines the number of equal-width bins in the given range
  83. If bins is a sequence, it defines a monotonically increasing array of bin edges, including the rightmost edge, allowing for non-uniform bin widths.
  84. If bins is a string, it defines the method used to calculate the optimal bin width, as defined by
  85. https://numpy.org/doc/stable/reference/generated/numpy.histogram_bin_edges.html#numpy.histogram_bin_edges
  86. one of [‘sqrt’, ’auto’, ‘fd’, ‘doane’, ‘scott’, ‘stone’...]
  87. :param global_step: Global step value to record
  88. """
  89. raise NotImplementedError
  90. @abstractmethod
  91. def add_text(self, tag: str, text_string: str, global_step: int = None):
  92. """
  93. Add a text to SGLogger.
  94. Typically, this function will add a text to tensorboard or add it to experiment management framework.
  95. :param tag: Data identifier
  96. :param text_string: the text to be added
  97. :param global_step: Global step value to record
  98. """
  99. raise NotImplementedError
  100. @abstractmethod
  101. def add_checkpoint(self, tag: str, state_dict: dict, global_step: int = None):
  102. """
  103. Add a checkpoint to SGLogger
  104. Typically, this function will write a torch file to disk, upload it to remote storage or to experiment management framework.
  105. :param tag: Data identifier
  106. :param state_dict: the state dict to save. The state dict includes more than just the model weight and may include any of:
  107. net: model weights
  108. acc: current accuracy (depends on metrics)
  109. epoch: current epoch
  110. optimizer_state_dict: optimizer state
  111. scaler_state_dict: torch.amp.scaler sate
  112. :param global_step: Global step value to record
  113. """
  114. raise NotImplementedError
  115. @abstractmethod
  116. def add_file(self, file_name: str = None):
  117. """
  118. Add a file from the checkpoint directory to the logger (usually, upload the file or adds it to an artifact)
  119. """
  120. raise NotImplementedError
  121. @abstractmethod
  122. def upload(self):
  123. """
  124. Upload any files which should be stored on remote storage
  125. """
  126. raise NotImplementedError
  127. @abstractmethod
  128. def flush(self):
  129. """
  130. Flush the SGLogger's cache
  131. """
  132. raise NotImplementedError
  133. @abstractmethod
  134. def close(self):
  135. """
  136. Close the SGLogger
  137. """
  138. raise NotImplementedError
  139. @abstractmethod
  140. def local_dir(self) -> str:
  141. """
  142. A getter for the full/absolute path where all files are saved locally
  143. :return:
  144. """
  145. raise NotImplementedError
Discard
Tip!

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