Upload model weights to the Artifacts of a finished run

I was training a yolov5 model, using the pre-configured wandb settings. But the weights weren’t uploaded because the session was killed. I tried wandb sync path/to/run but the model file didn’t get synced.

I want to upload the resulting best.pt file to the artifacts regardless without messing up with the current summary and results of the finished run. I looked up in the documentation and tried multiple guides but couldn’t manage to do that.

TL;DR: I have a finished run and a weights file. I need to upload the weights file as a model artifact to that finished run using the run path.

hey @alyetama , I think you can 1) resume the run 2) upload the model weights to that run

  1. Resume a run

Pass your run_id to wandb.init to resume the run. You can get the id from the url of the run page or from the “info” section (click the (i) button in the top left corner of the run page.

wandb.init(id=run_id, resume="must")
  1. Upload an artifact to that run
wandb.log_artifact(file_path, name='new_artifact', type='model') 

wandb.finish()
1 Like

Hey @alyetama, here is a code snippet you can use: https://docs.wandb.ai/guides/artifacts/artifacts-faqs#how-do-i-log-an-artifact-to-an-existing-run

1 Like

This initially uploaded my artifact to a different project. But it worked after I specified the project name in wandb.init.
Thanks!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.