Skip to content

Commit

Permalink
Fix load_checkpoint encoder prefix (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
anwai98 authored Dec 20, 2023
1 parent cc4fe4b commit d736b77
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions micro_sam/training/joint_sam_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ def load_checkpoint(self, checkpoint="best"):
# let's get the image encoder params from sam
sam_state = save_dict["model_state"]
encoder_state = []
prune_prefix = "sam.image_"
for k, v in sam_state.items():
if k.startswith("image_encoder"):
encoder_state.append((k, v))
if k.startswith(prune_prefix):
encoder_state.append((k[len(prune_prefix):], v))
encoder_state = OrderedDict(encoder_state)

# let's get the decoder params from unetr
Expand Down

0 comments on commit d736b77

Please sign in to comment.