Skip to content

Commit

Permalink
bug in normalize params for training
Browse files Browse the repository at this point in the history
  • Loading branch information
carsen-stringer committed Feb 15, 2024
1 parent b7902f3 commit 49771df
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cellpose/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1742,15 +1742,16 @@ def set_normalize_params(self, normalize_params):

def check_percentile_params(self, percentile):
# check normalization params
if not (percentile[0] >= 0 and percentile[1] > 0 and percentile[0] < 100 and percentile[1] <= 100
if percentile is not None and not (percentile[0] >= 0 and percentile[1] > 0 and percentile[0] < 100 and percentile[1] <= 100
and percentile[1] > percentile[0]):
print('GUI_ERROR: percentiles need be between 0 and 100, and upper > lower, using defaults')
self.norm_edits[0].setText('1.')
self.norm_edits[1].setText('99.')
percentile = [1., 99.]
else:
self.norm_edits[0].setText(str(percentile[0]))
self.norm_edits[1].setText(str(percentile[1]))
elif percentile is None:
percentile = [1., 99.]
self.norm_edits[0].setText(str(percentile[0]))
self.norm_edits[1].setText(str(percentile[1]))
return percentile

def check_filter_params(self, sharpen, smooth, tile_norm, smooth3D, norm3D, invert):
Expand Down Expand Up @@ -1967,7 +1968,6 @@ def train_model(self, restore=None, normalize_params=normalize_default):
model_type = None
self.logger.info(f'training new model starting from scratch')
self.current_model = model_type

self.channels = self.get_channels()
self.logger.info(f'training with chan = {self.ChannelChoose[0].currentText()}, chan2 = {self.ChannelChoose[1].currentText()}')

Expand All @@ -1980,7 +1980,7 @@ def train_model(self, restore=None, normalize_params=normalize_default):
self.new_model_path = train.train_seg(self.model.net, train_data=self.train_data,
train_labels=self.train_labels,
channels=self.channels,
normalize=self.get_normalize_params(),
normalize=normalize_params,
min_train_masks=0,
save_path=save_path,
nimg_per_epoch=8,
Expand Down

0 comments on commit 49771df

Please sign in to comment.