Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
allow test for any checkpoint (#874)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangg12 authored and fmassa committed Jun 12, 2019
1 parent 5b20697 commit 7ee52a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions maskrcnn_benchmark/utils/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def save(self, name, **kwargs):
torch.save(data, save_file)
self.tag_last_checkpoint(save_file)

def load(self, f=None):
if self.has_checkpoint():
def load(self, f=None, use_latest=True):
if self.has_checkpoint() and use_latest:
# override argument with existing checkpoint
f = self.get_checkpoint_file()
if not f:
Expand Down
7 changes: 6 additions & 1 deletion tools/test_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ def main():
help="path to config file",
)
parser.add_argument("--local_rank", type=int, default=0)
parser.add_argument(
"--ckpt",
help="The path to the checkpoint for test, default is the latest checkpoint.",
default=None,
)
parser.add_argument(
"opts",
help="Modify config options using the command-line",
Expand Down Expand Up @@ -73,7 +78,7 @@ def main():

output_dir = cfg.OUTPUT_DIR
checkpointer = DetectronCheckpointer(cfg, model, save_dir=output_dir)
_ = checkpointer.load(cfg.MODEL.WEIGHT)
_ = checkpointer.load(args.ckpt, use_latest=args.ckpt is None)

iou_types = ("bbox",)
if cfg.MODEL.MASK_ON:
Expand Down

0 comments on commit 7ee52a4

Please sign in to comment.