Unanswered
			
			
 
			
	
		
			
		
		
		
		
	
			
 				
					
		
		Hi All,
I'M Using Pytorch-Lightning With The Tensoboard Logger:
Here Is The Logging Code That Logs Images With The Tensoboard Logger.
Hi all,
I'm using Pytorch-Lightning with the Tensoboard logger:
Here is the logging code that logs images with the Tensoboard logger.
    def validation_step(self, batch, batch_idx):
        val_loss = self.__compute_loss(batch=batch, batch_idx=batch_idx)
        if batch_idx % 1 == 0:  # Log every 10 batches
            self.__log_tb_images(batch, batch_idx, val_loss)
        self.log("val_loss", val_loss)
    def __log_tb_images(self, batch, batch_idx, val_loss) -> None:
        imgs, y_true = batch
        y_pred = self(imgs)
        # Get tensorboard logger
        tb_logger = None
        for logger in self.trainer.loggers:
            if isinstance(logger, pl.loggers.TensorBoardLogger):
                tb_logger = logger.experiment
                break
        if tb_logger is None:
            raise ValueError('TensorBoard Logger not found')
        viz_batch = (imgs, y_true, y_pred, [batch_idx])
        # Log the images (Give them different names)
        for img_idx, (image, y_true, y_pred, batch_idx) in enumerate(zip(*viz_batch)):
            tb_logger.add_image(f"Image/{batch_idx}_{img_idx}", image, 0)
            tb_logger.add_image(
                f"GroundTruth/{batch_idx}_{img_idx}", y_true, 0)
            tb_logger.add_image(f"Prediction/{batch_idx}_{img_idx}", y_pred, 0)
According to: None logging to tensorboard get's automatically supported. But using the Tensorboard logger from pytorch lightning logging: None didn't work automatically for me. At least when I logged images those didn't show up in clearml. Would I need to write a custom pytorch lightning logger: None ; that call into the the manual logger from clearml: None ?
2K Views
				0
Answers
				
					 
	2 years ago
				
					
						 
	2 years ago
					
					 Tags
					
			