This file contains 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.compile(optimizer='adam', | |
loss = 'binary_crossentropy', | |
metrics=['accuracy']) | |
callback = keras.callbacks.EarlyStopping(monitor='val_loss', | |
patience=3, | |
restore_best_weights=True) |
This file contains 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
#We can also log the decision tree classifier parameters. | |
decision_tree_params ={ | |
"n_estimators": { | |
"type": "discrete", | |
"values": [50, 100, 150, 200, 250, 300] | |
}, | |
"criterion": { | |
"type": "categorical", | |
"values": ["gini", "entropy"] | |
}, |
This file contains 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
import os | |
from PIL import Image | |
def image_crop(row): | |
input_dir = 'Images\SampleImages' | |
output_dir = 'Images\cropped_Images' | |
# open image | |
im = Image.open(f"{input_dir}\{row['filename']}") |
This file contains 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
hyperparams = { | |
"batch_size": 32, | |
"epochs": 20, | |
"num_nodes": 64, | |
"activation": 'relu', | |
"optimizer": 'adam', | |
} | |
experiment.log_parameters(hyperparams) |
This file contains 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
import pandas as pd | |
import torch | |
import torchvision | |
from torchvision.transforms import transforms | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from sklearn.model_selection import train_test_split | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import comet_ml |
This file contains 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
label_data = pd.read_csv("facial_keypoints.csv") | |
label_data.head(5) | |
label_data.shape | |
label_data.describe() | |
label_data.info() | |
label_data = label_data.dropna() | |
label_index = label_data.index |
This file contains 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
image_data = np.load("face_images.npz") | |
image_data = image_data["face_images"] | |
image_data = np.transpose(image_data,(2,0,1)) | |
full_image = np.expand_dims(image_data[label_index],1) | |
full_image |
This file contains 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
experiment = comet_ml.Experiment( | |
api_key="API KEY", | |
project_name="face-landmarks-recognition", | |
workspace="WORKSPACE-NAME", | |
log_code=True) | |
hyperparameters = { | |
"batch_size": 32, | |
"epochs": 30, | |
"test_size": 0.1, |
This file contains 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
X_train,X_test,y_train,y_test = train_test_split(full_image,full_label,test_size = 0.1) |
This file contains 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
class FaceDataset(torch.utils.data.Dataset): | |
def __init__(self,image,label): | |
self.image = image | |
self.label = label | |
def __len__(self): | |
return len(self.image) | |
def __getitem__(self,idx): | |
image = self.image[idx] / 255. |