Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions imageai/Detection/Custom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def setTrainConfig(self, object_names_array, batch_size=4, num_experiments=100,

print("Detection configuration saved in ", os.path.join(self.__json_directory, "detection_config.json"))

def trainModel(self):
def trainModel(self, mode='min', monitor='loss'):

"""
'trainModel()' function starts the actual model training. Once the training starts, the training instance
Expand Down Expand Up @@ -278,7 +278,7 @@ def trainModel(self):
###############################
# Kick off the training
###############################
callbacks = self._create_callbacks(self.__train_weights_name, infer_model)
callbacks = self._create_callbacks(self.__train_weights_name, infer_model, mode=mode, monitor=monitor)

train_model.fit_generator(
generator=train_generator,
Expand Down Expand Up @@ -483,15 +483,15 @@ def _create_training_instances(self,

return train_ints, valid_ints, sorted(labels), max_box_per_image

def _create_callbacks(self, saved_weights_name, model_to_save):
def _create_callbacks(self, saved_weights_name, model_to_save, mode='min', monitor='loss'):

checkpoint = CustomModelCheckpoint(
model_to_save=model_to_save,
filepath=saved_weights_name + 'ex-{epoch:03d}--loss-{loss:08.3f}.h5',
monitor='loss',
monitor= monitor,
verbose=0,
save_best_only=True,
mode='min',
mode= mode,
period=1
)
reduce_on_plateau = ReduceLROnPlateau(
Expand Down
2 changes: 1 addition & 1 deletion imageai/Detection/Custom/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def call(self, x):
loss = loss_xy + loss_wh + loss_conf + loss_class


return loss*self.grid_scale
return loss*self.grid_scale + 1e-20

def compute_output_shape(self, input_shape):
return [(None, 1)]
Expand Down