format files

This commit is contained in:
ashleve committed 2021-04-26 14:32:25 +02:00
1 parent 36bd4c3f11
commit 5cc767a595
1 file changed
+14 -8
+14 -8
View File
@@ -200,8 +200,8 @@ class LogF1PrecRecHeatmapToWandb(Callback):
class ImagePredictionLogger(Callback): class ImagePredictionLogger(Callback):
"""Logs a validation batch and their predictions to wandb. """Logs a validation batch and their predictions to wandb.
Example adapted from: Example adapted from:
https://wandb.ai/wandb/wandb-lightning/reports/Image-Classification-using-PyTorch-Lightning--VmlldzoyODk1NzY https://wandb.ai/wandb/wandb-lightning/reports/Image-Classification-using-PyTorch-Lightning--VmlldzoyODk1NzY
""" """
def __init__(self, num_samples: int = 8): def __init__(self, num_samples: int = 8):
@@ -231,9 +231,15 @@ class ImagePredictionLogger(Callback):
preds = torch.argmax(logits, axis=-1) preds = torch.argmax(logits, axis=-1)
# log the images as wandb Image # log the images as wandb Image
experiment.log({ experiment.log(
f"Images/{experiment.name}":[wandb.Image(x, caption=f"Pred:{pred}, Label:{y}") {
for x, pred, y in zip(val_imgs[:self.num_samples], f"Images/{experiment.name}": [
preds[:self.num_samples], wandb.Image(x, caption=f"Pred:{pred}, Label:{y}")
val_labels[:self.num_samples])] for x, pred, y in zip(
}) val_imgs[: self.num_samples],
preds[: self.num_samples],
val_labels[: self.num_samples],
)
]
}
)