Skip to content

Commit

Permalink
modify config files
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketFlash committed Dec 17, 2019
1 parent 7ad9127 commit 51a16e9
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 296 deletions.
2 changes: 1 addition & 1 deletion configs/road_signs_resnet18.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ softmax_steps_per_epoch : 500
softmax_epochs : 20

#paths
work_dir : 'work_dirs/plates/'
work_dir : 'work_dirs/road_signs_resnet18/'
dataset_path : '/home/rauf/datasets/road_signs/road_signs_separated/'
plot_history : True
encodings_path : 'encodings/'
Expand Down
6 changes: 3 additions & 3 deletions configs/road_signs_resnet34.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ softmax_steps_per_epoch : 500
softmax_epochs : 20

#paths
work_dir : 'work_dirs/plates/'
work_dir : 'work_dirs/road_signs_resnext34/'
dataset_path : '/home/rauf/datasets/road_signs/road_signs_separated/'
plot_history : True
encodings_path : 'encodings/'
model_save_name : 'best_model_resnet18.h5'
encodings_save_name: 'encodings_resnet18.pkl'
model_save_name : 'best_model_resnet34.h5'
encodings_save_name: 'encodings_resnet34.pkl'

# encodings parameters
save_encodings : True
Expand Down
6 changes: 3 additions & 3 deletions configs/road_signs_resnext50.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ softmax_steps_per_epoch : 500
softmax_epochs : 20

#paths
work_dir : 'work_dirs/plates/'
work_dir : 'work_dirs/road_signs_resnext50/'
dataset_path : '/home/rauf/datasets/road_signs/road_signs_separated/'
plot_history : True
encodings_path : 'encodings/'
model_save_name : 'best_model_resnet18.h5'
encodings_save_name: 'encodings_resnet18.pkl'
model_save_name : 'best_model_resnext50.h5'
encodings_save_name: 'encodings_resnext50.pkl'

# encodings parameters
save_encodings : True
Expand Down
4 changes: 2 additions & 2 deletions embedding_net/backbones.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get_backbone(input_shape,
base_model = Model(
inputs=[input_image], outputs=[encoded_output])
else:
from classification_models import Classifiers
from classification_models.keras import Classifiers
classifier, preprocess_input = Classifiers.get(backbone_type)
backbone_model = classifier(input_shape=input_shape,
weights=backbone_weights,
Expand All @@ -82,7 +82,7 @@ def get_backbone(input_shape,

after_backbone = backbone_model.output
x = Flatten()(after_backbone)

encoded_output = Dense(encodings_len, activation="relu")(x)
if embeddings_normalization:
encoded_output = Lambda(lambda x: K.l2_normalize(
Expand Down
5 changes: 2 additions & 3 deletions embedding_net/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,8 @@ def generate_encodings(self, save_file_name='encodings.pkl', only_centers=False,
n_neighbors=k_val)
self.encoded_training_data['knn_classifier'].fit(self.encoded_training_data['encodings'],
self.encoded_training_data['labels'])
f = open(save_file_name, "wb")
pickle.dump(self.encoded_training_data, f)
f.close()
with open(save_file_name, "wb") as f
pickle.dump(self.encoded_training_data, f)

def load_encodings(self, path_to_encodings):
self.encoded_training_data = load_encodings(path_to_encodings)
Expand Down
5 changes: 3 additions & 2 deletions embedding_net/pretrain_backbone_softmax.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ def pretrain_backbone_softmax(input_model, cfg_params):
train_generator = image_loader.generate(batch_size, s="train")
val_generator = image_loader.generate(batch_size, s="val")

tensorboard_save_path = os.path.join(
cfg_params['work_dir'], 'tf_log/pretraining_model/')
callbacks = [
ReduceLROnPlateau(monitor='val_loss', factor=0.1,
patience=4, verbose=1),
EarlyStopping(patience=50, verbose=1),
TensorBoard(log_dir='tf_log/')
TensorBoard(log_dir=tensorboard_save_path)
]

history = model.fit_generator(train_generator,
Expand Down
Loading

0 comments on commit 51a16e9

Please sign in to comment.