Skip to content

Commit

Permalink
reorganize code
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketFlash committed Jun 19, 2020
1 parent 11affca commit e57860a
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 425 deletions.
4 changes: 1 addition & 3 deletions embedding_net/backbones.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def get_backbone(input_shape,
backbone_model = Model(
inputs=[input_image], outputs=[x])
x = Flatten()(x)
print(backbone_model.output)
x = Dense(512, activation="relu")(x)
x = Dropout(0.5)(x)
encoded_output = Dense(encodings_len, activation='relu',
Expand Down Expand Up @@ -195,8 +194,7 @@ def pretrain_backbone_softmax(backbone_model, data_loader, params_softmax, para
verbose=1,
monitor=checkpoint_callback_monitor,
save_best_only=True)]
# checkpoints_load_name = 'work_dirs/bengali_efficientnet/pretraining_model/weights/bengali_efficientnet_020_0.932969.h5'
# model.load_weights(checkpoints_load_name, by_name=True)

history = model.fit_generator(train_generator,
steps_per_epoch=steps_per_epoch,
epochs=n_epochs,
Expand Down
385 changes: 0 additions & 385 deletions embedding_net/data_loader.py

This file was deleted.

28 changes: 0 additions & 28 deletions embedding_net/losses_and_accuracies.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,3 @@ def accuracy(y_true, y_pred):
'''
return K.mean(K.equal(y_true, K.cast(y_pred < 0.5, y_true.dtype)))


# class tSNECallback(keras.callbacks.Callback):

# def __init__(self, save_file_name='tSNE.gif'):
# super(tSNECallback, self).__init__()
# self.save_file_name = save_file_name

# def on_train_begin(self, logs={}):
# self.aucs = []
# self.losses = []

# def on_train_end(self, logs={}):
# return

# def on_epoch_begin(self, epoch, logs={}):
# return

# def on_epoch_end(self, epoch, logs={}):
# self.losses.append(logs.get('loss'))
# y_pred = self.model.predict(self.model.validation_data[0])
# self.aucs.append(roc_auc_score(self.model.validation_data[1], y_pred))
# return

# def on_batch_begin(self, batch, logs={}):
# return

# def on_batch_end(self, batch, logs={}):
# return
Binary file removed example_signs.jpg
Binary file not shown.
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
image-classifiers
keras==2.2.5
tensorflow-gpu==1.14.0
tensorflow-gpu==2.1.0
matplotlib
albumentations
scikit-learn
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 0 additions & 7 deletions train.py → tools/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def main():
metric = {'output_siamese' : accuracy,
'output_im1' : 'binary_accuracy',
'output_im2' : 'binary_accuracy'}
# metric = accuracy
else:
model = TripletNet(cfg_params, training=True)
train_generator = TripletsDataGenerator(embedding_model=model.base_model,
Expand All @@ -150,8 +149,6 @@ def main():
if args.resume_from is not None:
model.load_model(args.resume_from)

# model.load_model('/home/rauf/Desktop/sg_efficientnet-b3__simple_fold_0_005_0.9810.hdf5')
model.base_model.load_weights('/home/rauf/Desktop/sg_efficientnet-b3__simple_fold_0_005_0.9810.hdf5', by_name=True)
if 'softmax' in cfg_params:
params_softmax = cfg_params['softmax']
params_save_paths = cfg_params['save_paths']
Expand All @@ -167,10 +164,6 @@ def main():
verbose=1,
use_multiprocessing=False)

# encoded_training_data = model.generate_encodings(data_loader,
# max_n_samples=50000000000000000, shuffle=False)
# model.save_encodings(encoded_training_data)

if params_train['plot_history']:
plot_grapths(history, plots_save_path)

Expand Down

0 comments on commit e57860a

Please sign in to comment.