Spaces:
Running
Running
Update det-metrics.py
Browse files- det-metrics.py +26 -1
det-metrics.py
CHANGED
@@ -342,13 +342,38 @@ class DetectionMetric(evaluate.Metric):
|
|
342 |
return fig
|
343 |
|
344 |
def wandb(self, results , wandb_project='detection_metrics'):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
import os
|
346 |
import wandb
|
347 |
import datetime
|
348 |
|
349 |
current_datetime = datetime.datetime.now()
|
350 |
formatted_datetime = current_datetime.strftime("%Y-%m-%d_%H-%M-%S")
|
351 |
-
wandb.login(key=os.getenv('
|
352 |
|
353 |
for k in results.keys():
|
354 |
run = wandb.init(project=wandb_project, name=f"{k}-{formatted_datetime}")
|
|
|
342 |
return fig
|
343 |
|
344 |
def wandb(self, results , wandb_project='detection_metrics'):
|
345 |
+
"""
|
346 |
+
Logs metrics to Weights and Biases (wandb) for tracking and visualization.
|
347 |
+
|
348 |
+
This function logs the provided metrics to Weights and Biases (wandb), a platform for tracking machine learning experiments.
|
349 |
+
Each key in the `results` dictionary represents a separate run and the corresponding value contains the metrics for that run.
|
350 |
+
The function logs in to wandb using an API key obtained from the secret 'WANDB_API_KEY', initializes a run for
|
351 |
+
each key in `results` and logs the metrics.
|
352 |
+
|
353 |
+
Args:
|
354 |
+
results (dict): A dictionary where each key is a unique identifier for a run and each value is another dictionary
|
355 |
+
containing the metrics to log. Example:
|
356 |
+
{
|
357 |
+
"run1": {"metrics": {"accuracy": 0.9, "loss": 0.1}},
|
358 |
+
"run2": {"metrics": {"accuracy": 0.85, "loss": 0.15}}
|
359 |
+
}
|
360 |
+
wandb_project (str, optional): The name of the wandb project to which the runs will be logged. Defaults to 'detection_metrics'.
|
361 |
+
|
362 |
+
Environment Variables:
|
363 |
+
WANDB_API_KEY: The API key for authenticating with wandb.
|
364 |
+
|
365 |
+
Imports:
|
366 |
+
os: To retrieve environment variables.
|
367 |
+
wandb: To interact with the Weights and Biases platform.
|
368 |
+
datetime: To generate a timestamp for run names.
|
369 |
+
"""
|
370 |
import os
|
371 |
import wandb
|
372 |
import datetime
|
373 |
|
374 |
current_datetime = datetime.datetime.now()
|
375 |
formatted_datetime = current_datetime.strftime("%Y-%m-%d_%H-%M-%S")
|
376 |
+
wandb.login(key=os.getenv('WANDB_API_KEY'))
|
377 |
|
378 |
for k in results.keys():
|
379 |
run = wandb.init(project=wandb_project, name=f"{k}-{formatted_datetime}")
|