From 80e9bed0dd9840ac0cc9de1c6c1be3b6fed90cf9 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Mon, 5 Jul 2021 00:22:27 +0200 Subject: Add new updates to model and networks, reimplementing with attr --- text_recognizer/callbacks/wandb_callbacks.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'text_recognizer/callbacks') diff --git a/text_recognizer/callbacks/wandb_callbacks.py b/text_recognizer/callbacks/wandb_callbacks.py index 3936aaf..900c3b1 100644 --- a/text_recognizer/callbacks/wandb_callbacks.py +++ b/text_recognizer/callbacks/wandb_callbacks.py @@ -29,6 +29,9 @@ class WatchModel(Callback): log: str = attr.ib(default="gradients") log_freq: int = attr.ib(default=100) + def __attrs_pre_init__(self): + super().__init__() + def on_train_start(self, trainer: Trainer, pl_module: LightningModule) -> None: """Watches model weights with wandb.""" logger = get_wandb_logger(trainer) @@ -41,6 +44,9 @@ class UploadCodeAsArtifact(Callback): project_dir: Path = attr.ib(converter=Path) + def __attrs_pre_init__(self): + super().__init__() + def on_train_start(self, trainer: Trainer, pl_module: LightningModule) -> None: """Uploads project code as an artifact.""" logger = get_wandb_logger(trainer) @@ -59,6 +65,9 @@ class UploadCheckpointAsArtifact(Callback): ckpt_dir: Path = attr.ib(converter=Path) upload_best_only: bool = attr.ib() + def __attrs_pre_init__(self): + super().__init__() + def on_train_end(self, trainer: Trainer, pl_module: LightningModule) -> None: """Uploads model checkpoint to W&B.""" logger = get_wandb_logger(trainer) -- cgit v1.2.3-70-g09d2