format files
This commit is contained in:
1 parent
36bd4c3f11
commit
5cc767a595
2 files changed
+17
-11
No files matched your search
@@ -196,12 +196,12 @@ class LogF1PrecRecHeatmapToWandb(Callback):
|
||||
|
||||
self.preds.clear()
|
||||
self.targets.clear()
|
||||
|
||||
|
||||
|
||||
class ImagePredictionLogger(Callback):
|
||||
"""Logs a validation batch and their predictions to wandb.
|
||||
Example adapted from:
|
||||
https://wandb.ai/wandb/wandb-lightning/reports/Image-Classification-using-PyTorch-Lightning--VmlldzoyODk1NzY
|
||||
Example adapted from:
|
||||
https://wandb.ai/wandb/wandb-lightning/reports/Image-Classification-using-PyTorch-Lightning--VmlldzoyODk1NzY
|
||||
"""
|
||||
|
||||
def __init__(self, num_samples: int = 8):
|
||||
@@ -220,7 +220,7 @@ class ImagePredictionLogger(Callback):
|
||||
if self.ready:
|
||||
logger = get_wandb_logger(trainer=trainer)
|
||||
experiment = logger.experiment
|
||||
|
||||
|
||||
# get a validation batch from the validation dat loader
|
||||
val_samples = next(iter(trainer.datamodule.val_dataloader()))
|
||||
val_imgs, val_labels = val_samples
|
||||
@@ -231,9 +231,15 @@ class ImagePredictionLogger(Callback):
|
||||
preds = torch.argmax(logits, axis=-1)
|
||||
|
||||
# log the images as wandb Image
|
||||
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],
|
||||
preds[:self.num_samples],
|
||||
val_labels[:self.num_samples])]
|
||||
})
|
||||
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],
|
||||
preds[: self.num_samples],
|
||||
val_labels[: self.num_samples],
|
||||
)
|
||||
]
|
||||
}
|
||||
)
|
||||
Reference in new issue
Block a user