Skip to content

Commit

Permalink
Merge branch 'master' into label-scale-models
Browse files Browse the repository at this point in the history
  • Loading branch information
willgraf committed Aug 29, 2019
2 parents 76f2d81 + a1aad5b commit 2d039b0
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 86 deletions.
16 changes: 8 additions & 8 deletions deepcell/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
def train_model_sample(model,
dataset,
expt='',
test_size=.1,
test_size=.2,
n_epoch=10,
batch_size=32,
num_gpus=None,
Expand All @@ -72,7 +72,7 @@ def train_model_sample(model,
flip=False,
shear=0,
zoom_range=0,
seed=None,
seed=0,
**kwargs):
"""Train a model using sample mode.
Expand Down Expand Up @@ -217,7 +217,7 @@ def loss_function(y_true, y_pred):
def train_model_conv(model,
dataset,
expt='',
test_size=.1,
test_size=.2,
n_epoch=10,
batch_size=1,
num_gpus=None,
Expand All @@ -234,7 +234,7 @@ def train_model_conv(model,
flip=True,
shear=0,
zoom_range=0,
seed=None,
seed=0,
**kwargs):
"""Train a model using fully convolutional mode.
Expand Down Expand Up @@ -409,7 +409,7 @@ def loss_function(y_true, y_pred):
def train_model_siamese_daughter(model,
dataset,
expt='',
test_size=.1,
test_size=.2,
n_epoch=100,
batch_size=1,
num_gpus=None,
Expand All @@ -428,7 +428,7 @@ def train_model_siamese_daughter(model,
flip=True,
shear=0,
zoom_range=0,
seed=None,
seed=0,
**kwargs):
is_channels_first = K.image_data_format() == 'channels_first'

Expand Down Expand Up @@ -545,7 +545,7 @@ def loss_function(y_true, y_pred):
def train_model_retinanet(model,
dataset,
expt='',
test_size=.1,
test_size=.2,
n_epoch=10,
batch_size=1,
num_gpus=None,
Expand Down Expand Up @@ -575,7 +575,7 @@ def train_model_retinanet(model,
shear=0,
zoom_range=0,
compute_map=True,
seed=None,
seed=0,
**kwargs):
"""Train a RetinaNet model from the given backbone.
Expand Down
2 changes: 1 addition & 1 deletion deepcell/utils/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
from deepcell.utils.tracking_utils import load_trks


def get_data(file_name, mode='sample', test_size=.1, seed=None):
def get_data(file_name, mode='sample', test_size=.2, seed=0):
"""Load data from NPZ file and split into train and test sets
Args:
Expand Down
7 changes: 5 additions & 2 deletions scripts/feature_pyramids/PanOpticFPN.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
"source": [
"# Download the data (saves to ~/.keras/datasets)\n",
"filename = 'HeLa_S3.npz'\n",
"(X_train, y_train), (X_test, y_test) = deepcell.datasets.hela_s3.load_data(filename)\n",
"test_size = 0.2 # % of data saved as test\n",
"seed = 0 # seed for random train-test split\n",
"\n",
"(X_train, y_train), (X_test, y_test) = deepcell.datasets.hela_s3.load_data(filename, test_size=test_size, seed=seed)\n",
"\n",
"print('X.shape: {}\\ny.shape: {}'.format(X_train.shape, y_train.shape))"
]
Expand Down Expand Up @@ -118,7 +121,6 @@
"model_name = '{}_retinanet'.format(backbone)\n",
"\n",
"n_epoch = 5 # Number of training epochs\n",
"test_size = .20 # % of data saved as test\n",
"lr = 1e-5\n",
"\n",
"optimizer = Adam(lr=lr, clipnorm=0.001)\n",
Expand Down Expand Up @@ -285,6 +287,7 @@
" iou_threshold=0.5,\n",
" max_detections=100,\n",
" test_size=test_size,\n",
" seed=seed,\n",
" optimizer=optimizer,\n",
" batch_size=batch_size,\n",
" n_epoch=n_epoch,\n",
Expand Down
7 changes: 5 additions & 2 deletions scripts/feature_pyramids/RetinaMask.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
"source": [
"# Download the data (saves to ~/.keras/datasets)\n",
"filename = 'HeLa_S3.npz'\n",
"(X_train, y_train), (X_test, y_test) = deepcell.datasets.hela_s3.load_data(filename)\n",
"test_size = 0.1 # % of data saved as test\n",
"seed = 0 # seed for random train-test split\n",
"\n",
"(X_train, y_train), (X_test, y_test) = deepcell.datasets.hela_s3.load_data(filename, test_size=test_size, seed=seed)\n",
"\n",
"print('X.shape: {}\\ny.shape: {}'.format(X_train.shape, y_train.shape))"
]
Expand Down Expand Up @@ -111,7 +114,6 @@
"backbone = 'resnet50' # vgg16, vgg19, resnet50, densenet121, densenet169, densenet201\n",
"\n",
"n_epoch = 3 # Number of training epochs\n",
"test_size = .10 # % of data saved as test\n",
"lr = 1e-5\n",
"\n",
"optimizer = Adam(lr=lr, clipnorm=0.001)\n",
Expand Down Expand Up @@ -251,6 +253,7 @@
" iou_threshold=0.5,\n",
" max_detections=100,\n",
" test_size=test_size,\n",
" seed=seed,\n",
" optimizer=optimizer,\n",
" batch_size=batch_size,\n",
" n_epoch=n_epoch,\n",
Expand Down
15 changes: 6 additions & 9 deletions scripts/feature_pyramids/RetinaNet.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
"source": [
"# Download the data (saves to ~/.keras/datasets)\n",
"filename = 'HeLa_S3.npz'\n",
"(X_train, y_train), (X_test, y_test) = deepcell.datasets.hela_s3.load_data(filename)\n",
"test_size = 0.2 # % of data saved as test\n",
"seed = 0 # seed for random train-test split\n",
"\n",
"(X_train, y_train), (X_test, y_test) = deepcell.datasets.hela_s3.load_data(filename, test_size=test_size, seed=seed)\n",
"\n",
"print('X.shape: {}\\ny.shape: {}'.format(X_train.shape, y_train.shape))"
]
Expand Down Expand Up @@ -118,7 +121,6 @@
"model_name = '{}_retinanet'.format(backbone)\n",
"\n",
"n_epoch = 20 # Number of training epochs\n",
"test_size = .20 # % of data saved as test\n",
"lr = 1e-5\n",
"\n",
"optimizer = Adam(lr=lr, clipnorm=0.001)\n",
Expand Down Expand Up @@ -290,13 +292,7 @@
"9978 instances of class 0 with average precision: 0.8226\n",
"mAP: 0.8226\n",
"160/160 [==============================] - 125s 781ms/step - loss: 0.7435 - regression_loss: 0.6493 - classification_loss: 0.0942 - val_loss: 0.5919 - val_regression_loss: 0.5273 - val_classification_loss: 0.0646\n",
"Epoch 16/20\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Epoch 16/20\n",
"159/160 [============================>.] - ETA: 0s - loss: 0.7279 - regression_loss: 0.6376 - classification_loss: 0.0902\n",
"Epoch 00016: val_loss did not improve from 0.59190\n",
"9978 instances of class 0 with average precision: 0.8234\n",
Expand Down Expand Up @@ -351,6 +347,7 @@
" iou_threshold=0.5,\n",
" max_detections=100,\n",
" test_size=test_size,\n",
" seed=seed,\n",
" optimizer=optimizer,\n",
" batch_size=batch_size,\n",
" n_epoch=n_epoch,\n",
Expand Down

0 comments on commit 2d039b0

Please sign in to comment.