Skip to content

Instantly share code, notes, and snippets.

View techwithshadab's full-sized avatar
💻
Playing with Data

Shadab Hussain techwithshadab

💻
Playing with Data
View GitHub Profile
# 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)
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'))
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 = []
model.fit(train, labs, batch_size=batch_size, epochs=nb_epoch,
validation_split=0.25, verbose=0, shuffle=True, callbacks=[history, early_stopping])
predictions = model.predict(test, verbose=0)
predictions
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()
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()
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
curl -I http://172.18.x.x:5000