Skip to content

Commit

Permalink
Bugfix for MaskRCNN creating empty log_dir that breaks find_last()
Browse files Browse the repository at this point in the history
- Current implementation creates self.log_dir in set_log_dir() function,
  which creates an empty log directory if none exists. This causes
  find_last() to fail after creating a model because it finds this new
  empty directory instead of the previous training directory.
- New implementation moves log_dir creation to the train() function to
  ensure it is only created when it will be used.
  • Loading branch information
akTwelve authored and waleedka committed Sep 21, 2018
1 parent 1aeb72d commit bde3fb5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mrcnn/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2274,10 +2274,6 @@ def set_log_dir(self, model_path=None):
self.log_dir = os.path.join(self.model_dir, "{}{:%Y%m%dT%H%M}".format(
self.config.NAME.lower(), now))

# Create log_dir if not exists
if not os.path.exists(self.log_dir):
os.makedirs(self.log_dir)

# Path to save after each epoch. Include placeholders that get filled by Keras.
self.checkpoint_path = os.path.join(self.log_dir, "mask_rcnn_{}_*epoch*.h5".format(
self.config.NAME.lower()))
Expand Down Expand Up @@ -2342,6 +2338,10 @@ def train(self, train_dataset, val_dataset, learning_rate, epochs, layers,
val_generator = data_generator(val_dataset, self.config, shuffle=True,
batch_size=self.config.BATCH_SIZE)

# Create log_dir if it does not exist
if not os.path.exists(self.log_dir):
os.makedirs(self.log_dir)

# Callbacks
callbacks = [
keras.callbacks.TensorBoard(log_dir=self.log_dir,
Expand Down

0 comments on commit bde3fb5

Please sign in to comment.