How to save checkpoints to Weights and baises ? #1222
sandeepgadhwal
started this conversation in
General
Replies: 1 comment 2 replies
-
Hi, you can implement a from mmengine.hooks import Hook
from mmengine.registry import HOOKS
@HOOKS.register_module()
class UploadCheckpointHook(Hook):
def after_train_epoch(runner):
wandb = runner.visualizer.get_backend('WandbVisBackend').experiment
# https://docs.wandb.ai/ref/python/save#docusaurus_skipToContent_fallback
wandb.save('checkpoint.pth', policy='now') The below is snippets code: runner = Runner(
model=MMResNet50(),
work_dir='./work_dir',
train_dataloader=train_dataloader,
optim_wrapper=dict(optimizer=dict(type=SGD, lr=0.001, momentum=0.9)),
train_cfg=dict(by_epoch=True, max_epochs=5, val_interval=1),
val_dataloader=val_dataloader,
val_cfg=dict(),
val_evaluator=dict(type=Accuracy),
# 1. set WandbVisBackend
visualizer=dict(type='Visualizer', vis_backends=[dict(type='WandbVisBackend')]),
# 2. set UploadCheckpointHook
custom_hooks = [dict(type='UploadCheckpointHook')]
)
runner.train() |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How to save checkpoints to Weights and baises ?
Beta Was this translation helpful? Give feedback.
All reactions