Skip to content

Commit a9f0c7c

Browse files
author
Fangchang Ma
authored
Merge pull request #25 from abdo-eldesokey/master
Bug fix in --resume mode
2 parents 65f5fa2 + b371b23 commit a9f0c7c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

main.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,17 @@ def main():
9797

9898
# optionally resume from a checkpoint
9999
elif args.resume:
100-
assert os.path.isfile(args.resume), \
101-
"=> no checkpoint found at '{}'".format(args.resume)
102-
print("=> loading checkpoint '{}'".format(args.resume))
103-
checkpoint = torch.load(args.resume)
100+
chkpt_path = args.resume
101+
assert os.path.isfile(chkpt_path), \
102+
"=> no checkpoint found at '{}'".format(chkpt_path)
103+
print("=> loading checkpoint '{}'".format(chkpt_path))
104+
checkpoint = torch.load(chkpt_path)
104105
args = checkpoint['args']
105106
start_epoch = checkpoint['epoch'] + 1
106107
best_result = checkpoint['best_result']
107108
model = checkpoint['model']
108109
optimizer = checkpoint['optimizer']
109-
output_directory = os.path.dirname(os.path.abspath(args.resume))
110+
output_directory = os.path.dirname(os.path.abspath(chkpt_path))
110111
print("=> loaded checkpoint (epoch {})".format(checkpoint['epoch']))
111112
train_loader, val_loader = create_data_loaders(args)
112113
args.resume = True

0 commit comments

Comments
 (0)