Документация логгеров¶
loggers ¶
Logger integrations for embeddings_squeeze.
Classes¶
ClearMLLogger ¶
ClearMLLogger(task)
Wrapper for ClearML logging compatible with PyTorch Lightning. Supports scalar metrics, plots, images, and text logging.
Source code in embeddings_squeeze\loggers\clearml_logger.py
124 125 126 |
|
Functions¶
log_metrics ¶
log_metrics(metrics, step=None)
Log metrics to ClearML.
Source code in embeddings_squeeze\loggers\clearml_logger.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
|
log_scalar ¶
log_scalar(title, series, value, iteration)
Log a single scalar value to ClearML.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title
|
str
|
Graph title (e.g., "loss", "accuracy") |
required |
series
|
str
|
Series name within the graph (e.g., "train", "val") |
required |
value
|
float
|
Scalar value to log |
required |
iteration
|
int
|
Iteration/step number |
required |
Example
logger.log_scalar("loss", "train", 0.5, iteration=100) logger.log_scalar("loss", "val", 0.3, iteration=100)
Source code in embeddings_squeeze\loggers\clearml_logger.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
log_image ¶
log_image(title, series, image, iteration)
Log an image to ClearML.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title
|
str
|
Image title/group |
required |
series
|
str
|
Series name (e.g., "predictions", "ground_truth") |
required |
image
|
Image as numpy array (H, W) or (H, W, C) for grayscale/RGB Supports uint8 (0-255) or float (0-1) |
required | |
iteration
|
int
|
Iteration/step number |
required |
Example
Grayscale image¶
img = np.eye(256, 256, dtype=np.uint8) * 255 logger.log_image("predictions", "epoch_1", img, iteration=0)
RGB image¶
img_rgb = np.zeros((256, 256, 3), dtype=np.uint8) img_rgb[:, :, 0] = 255 # Red channel logger.log_image("predictions", "epoch_1_rgb", img_rgb, iteration=0)
Source code in embeddings_squeeze\loggers\clearml_logger.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
log_images_batch ¶
log_images_batch(title, series, images, iteration)
Log multiple images to ClearML.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title
|
str
|
Image title/group |
required |
series
|
str
|
Series name |
required |
images
|
list
|
List of images (numpy arrays) |
required |
iteration
|
int
|
Iteration/step number |
required |
Example
images = [img1, img2, img3] logger.log_images_batch("samples", "batch_0", images, iteration=0)
Source code in embeddings_squeeze\loggers\clearml_logger.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|
log_text ¶
log_text(text, title='Info')
Log text to ClearML.
Source code in embeddings_squeeze\loggers\clearml_logger.py
228 229 230 231 232 |
|
report_text ¶
report_text(text)
Report text to ClearML (alias for log_text with default title).
Source code in embeddings_squeeze\loggers\clearml_logger.py
234 235 236 |
|
report_plotly ¶
report_plotly(title, series, iteration, figure)
Report a Plotly figure to ClearML.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title
|
str
|
Plot title/group |
required |
series
|
str
|
Series name |
required |
iteration
|
int
|
Iteration/step number |
required |
figure
|
Plotly figure object |
required |
Example
import plotly.graph_objects as go fig = go.Figure() fig.add_trace(go.Scatter(x=[1,2,3], y=[4,5,6], mode='lines', name='data')) fig.update_layout(title="My Plot", xaxis_title="x", yaxis_title="y") logger.report_plotly("metrics", "loss", iteration=0, figure=fig)
Source code in embeddings_squeeze\loggers\clearml_logger.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
|
finalize ¶
finalize()
Finalize logging and close task.
Source code in embeddings_squeeze\loggers\clearml_logger.py
265 266 267 268 |
|
ClearMLUploadCallback ¶
ClearMLUploadCallback(
task,
clearml_logger=None,
checkpoint_dir="checkpoints",
embedding_dir="embeddings",
)
Bases: Callback
PyTorch Lightning callback for logging checkpoint and embedding paths to ClearML.
Automatically logs local file paths for: - Latest checkpoint after each validation epoch - Per-epoch validation embeddings
Usage
from pytorch_lightning import Trainer from embeddings_squeeze.loggers import ClearMLUploadCallback, setup_clearml
task = setup_clearml(project_name="my_project", task_name="experiment_1") logger = ClearMLLogger(task) if task else None callback = ClearMLUploadCallback(task, logger, checkpoint_dir="checkpoints")
trainer = Trainer(callbacks=[callback], ...)
Initialize ClearML path logging callback.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task
|
Task
|
ClearML Task object |
required |
clearml_logger
|
ClearMLLogger
|
ClearML logger for text reporting (optional) |
None
|
checkpoint_dir
|
str
|
Directory containing checkpoints |
'checkpoints'
|
embedding_dir
|
str
|
Directory containing embeddings |
'embeddings'
|
Source code in embeddings_squeeze\loggers\clearml_logger.py
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
|
Functions¶
on_validation_epoch_end ¶
on_validation_epoch_end(trainer, pl_module)
Called after validation epoch ends.
Source code in embeddings_squeeze\loggers\clearml_logger.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
|
Functions¶
setup_clearml ¶
setup_clearml(project_name, task_name, auto_connect=True)
Setup ClearML with credentials from config file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name
|
str
|
ClearML project name |
required |
task_name
|
str
|
ClearML task name |
required |
auto_connect
|
bool
|
If True, automatically connect frameworks |
True
|
Returns:
Type | Description |
---|---|
Task object |
Source code in embeddings_squeeze\loggers\clearml_logger.py
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 |
|