This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# splitting path of all images into male and female | |
train_male_image = [] | |
train_female_image = [] | |
for each in train_image_name: | |
if each.split('/')[7] in train_male_data['Filename'].values: | |
train_male_image.append(each) | |
else: | |
train_female_image.append(each) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
optimizer = RMSprop(lr=1e-4) | |
objective = 'binary_crossentropy' | |
def malefemale(): | |
model = Sequential() | |
model.add(Convolution2D(32, 3, 3, border_mode='same', input_shape=(3, ROWS, COLS), activation='relu')) | |
model.add(Convolution2D(32, 3, 3, border_mode='same', activation='relu')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nb_epoch = 10 | |
batch_size = 16 | |
labs = train_data.iloc[:,1].values.tolist() | |
## Callback for loss logging per epoch | |
class LossHistory(Callback): | |
def on_train_begin(self, logs={}): | |
self.losses = [] | |
self.val_losses = [] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model.fit(train, labs, batch_size=batch_size, epochs=nb_epoch, | |
validation_split=0.25, verbose=0, shuffle=True, callbacks=[history, early_stopping]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
predictions = model.predict(test, verbose=0) | |
predictions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loss = history.losses | |
val_loss = history.val_losses | |
plt.xlabel('Epochs') | |
plt.ylabel('Loss') | |
plt.title('VGG-16 Loss Trend') | |
plt.plot(loss, 'blue', label='Training Loss') | |
plt.plot(val_loss, 'green', label='Validation Loss') | |
plt.xticks(range(0,nb_epoch)[0::2]) | |
plt.legend() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in range(0,6): | |
if predictions[i, 0] >= 0.5: | |
print('I am {:.2%} sure this is a Female'.format(predictions[i][0])) | |
else: | |
print('I am {:.2%} sure this is a Male'.format(1-predictions[i][0])) | |
plt.imshow(test[i].T) | |
plt.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model.summary() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt update | |
sudo apt upgrade | |
# Install pip | |
sudo apt install python-pip | |
# Install mlflow | |
pip install mlflow | |
# Check version of mlflow installed | |
mlflow --version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -I http://172.18.x.x:5000 |