Skip to content

Commit

Permalink
Allow dashes in model name.
Browse files Browse the repository at this point in the history
Print a message when re-starting from saved epoch
  • Loading branch information
Julien Rebetez authored and waleedka committed Jun 5, 2018
1 parent e0d1539 commit d0c52d7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mrcnn/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2222,14 +2222,15 @@ def set_log_dir(self, model_path=None):
# Continue from we left of. Get epoch and date from the file name
# A sample model path might look like:
# /path/to/logs/coco20171029T2315/mask_rcnn_coco_0001.h5
regex = r".*/\w+(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})/mask\_rcnn\_\w+(\d{4})\.h5"
regex = r".*/[\w-]+(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})/mask\_rcnn\_[\w-]+(\d{4})\.h5"
m = re.match(regex, model_path)
if m:
now = datetime.datetime(int(m.group(1)), int(m.group(2)), int(m.group(3)),
int(m.group(4)), int(m.group(5)))
# Epoch number in file is 1-based, and in Keras code it's 0-based.
# So, adjust for that then increment by one to start from the next epoch
self.epoch = int(m.group(6)) - 1 + 1
print('Re-starting from epoch %d' % self.epoch)

# Directory for training logs
self.log_dir = os.path.join(self.model_dir, "{}{:%Y%m%dT%H%M}".format(
Expand Down

0 comments on commit d0c52d7

Please sign in to comment.