Collab example for building an "evaluation" table using wandb.log()

Hi - in the wandb_example Workspace, there is a table visualisation showing “evaluation” results logged from a run:

My understanding is that this table has to be created using wandb.log() in the training code, but I can’t access the notebook used for the run in the example workspace.

I want to create a similar evaluation table using one of your examples: https://github.com/wandb/examples/examples/pytorch/pytorch-cnn-fashion/train.py

Is there a code snippet or collab example for doing this? I’ve seen the docs for logging a table, but I need a specific example like the one in the example workspace that shows clothing images, and metrics e.g. ‘guess’. ‘truth’ etc.

Thanks!

Hi @omerm,

I’m glad to hear you’re excited to log a wandb.Table. You can create a wandb.Table with wandb.Image, strings and floats for the values in each row, and then log it using wandb.log({'my_eval_table': table}).

# create a Table with the same columns as above,
# plus confidence scores for all labels
columns=["id", "image", "guess", "truth"]
for digit in range(10):
    columns.append("score_" + str(digit))
test_table = wandb.Table(columns=columns)

# run inference on every image, assuming my_model returns the
# predicted label, and the ground truth labels are available
for img_id, img in enumerate(mnist_test_data):
    true_label = mnist_test_data_labels[img_id]
    guess_label = my_model.predict(img)
    test_table.add_data(img_id, wandb.Image(img), \
                         guess_label, true_label)

Here is the colab used to create the table: Google Colab. If you’d rather a more direct introduction to wandb.Tables you can follow the guide here:
https://docs.wandb.ai/guides/data-vis/log-tables#create-tables

Hope that helps.

1 Like

That’s super helpful, thanks!

1 Like

That’s super helpful, thanks!

[Discourse post]

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.