From 262c0f8faa01edfedd0f3805a1a62eeb011b6a4c Mon Sep 17 00:00:00 2001 From: chaitanya-yeole Date: Wed, 31 Jul 2024 07:57:11 -0400 Subject: [PATCH] feat: Add logger to write to csv files. Signed-off-by: chaitanya-yeole Signed-off-by: ChaitanyaYeole02 --- src/anomalib/loggers/__init__.py | 2 ++ src/anomalib/loggers/csv_logger.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/anomalib/loggers/csv_logger.py diff --git a/src/anomalib/loggers/__init__.py b/src/anomalib/loggers/__init__.py index 8c47306ddc..a170500aaa 100644 --- a/src/anomalib/loggers/__init__.py +++ b/src/anomalib/loggers/__init__.py @@ -17,6 +17,7 @@ from .mlflow import AnomalibMLFlowLogger # noqa: F401 from .tensorboard import AnomalibTensorBoardLogger # noqa: F401 from .wandb import AnomalibWandbLogger # noqa: F401 + from .csv_logger import AnomalibCSVLogger __all__.extend( [ @@ -24,6 +25,7 @@ "AnomalibTensorBoardLogger", "AnomalibWandbLogger", "AnomalibMLFlowLogger", + "AnomalibCSVLogger", ], ) except ImportError: diff --git a/src/anomalib/loggers/csv_logger.py b/src/anomalib/loggers/csv_logger.py new file mode 100644 index 0000000000..1bdb5107db --- /dev/null +++ b/src/anomalib/loggers/csv_logger.py @@ -0,0 +1,19 @@ +from lightning.pytorch.loggers import CSVLogger + + +class AnomalibCSVLogger(CSVLogger): + def __init__( + self, + save_dir: str, + name: str | None = "default", + version: int | str | None = None, + prefix: str = "", + flush_logs_every_n_step: int | None = 100, + ) -> None: + super().__init__( + save_dir=save_dir, + name=name, + version=version, + prefix=prefix, + flush_logs_every_n_steps=flush_logs_every_n_step, + )