Hi all,
I am building custom charts (PR, ROC curve, Confusion Matrix and a Histogram). When I log them with wandb online
, all goes well. When I run wandb in offline
mode and then run wandb sync <run-directory
, I only see the related tables, not the CustomCharts, like line plots and histograms.
Why is wandb sync
not uploading the charts?
This is the code to reproduce my issue
import wandb
import os
wandb_mode = "online"
os.environ["WANDB_MODE"] = wandb_mode
project = "uncategorized"
run_id = "d57l24lc"
run = wandb.init(project=project)
def get_predictions():
labels = ["cat", "dog", "bird"]
ground_truth = [0, 1, 2, 0, 1, 2]
# Predictions of size # samples x # classes
predictions = [
[0.1, 0.2, 0.7],
[0.3, 0.4, 0.3],
[0.1, 0.2, 0.7],
[0.1, 0.2, 0.7],
[0.1, 0.2, 0.7],
[0.1, 0.2, 0.7],
]
return labels, ground_truth, predictions
def plot_pr_curve():
labels, ground_truth, predictions = get_predictions()
wandb.log({"pr": wandb.plot.pr_curve(ground_truth, predictions, labels)})
def plot_confusion_matrix():
labels, ground_truth, predictions = get_predictions()
run.log({"confusion_matrix": wandb.plot.confusion_matrix(probs=predictions, y_true=ground_truth, class_names=labels)})
def plot_roc_curve():
labels, ground_truth, predictions = get_predictions()
run.log({"roc": wandb.plot.roc_curve(ground_truth, predictions, labels)})
def plot_histogram():
import random
annotation_tasks_scores = [random.random() for _ in range(100)]
# Create data table with one column for the scores
data = [[s] for s in annotation_tasks_scores]
table = wandb.Table(data=data, columns=["scores"])
# Create histogram with custom binning
wandb.log({
"Annotation Tasks Scores Distribution": wandb.plot.histogram(
table,
"scores",
title="Annotation Tasks Scores Distribution",
)
})
plot_pr_curve()
plot_confusion_matrix()
plot_roc_curve()
plot_histogram()
wandb.finish()
You can simply make wandb_mode offline/online to test both beahaviors.
These are the custom charts that should be displayed after wandb sync
Thank you so much in advance!!