I hereby claim:
- I am adaltof on github.
- I am acorreia (https://keybase.io/acorreia) on keybase.
- I have a public key ASCrL4Ume03y_jaddsiGZ0e0hfwo4sawXNOcXdM3bKQR3Ao
To claim this, I am signing this object:
### Obtain bottleneck features from another pre-trained CNN. | |
filename = 'bottleneck_features/DogResnet50Data.npz' | |
bottleneck_url = 'https://s3-us-west-1.amazonaws.com/udacity-aind/dog-project/DogResnet50Data.npz' | |
if not exists(filename): | |
urllib.request.urlretrieve(bottleneck_url, filename) | |
bottleneck_features = np.load(filename) | |
train_new = bottleneck_features['train'] |
### Function that takes a path to an image as input | |
### and returns the dog breed that is predicted by the model. | |
def predict_breed(img_path): | |
# extract bottleneck features | |
bottleneck_feature = extract_Resnet50(path_to_tensor(img_path)) | |
# obtain predicted vector | |
predicted_vector = new_model.predict(bottleneck_feature) | |
# return dog breed that is predicted by the model | |
return dog_names[np.argmax(predicted_vector)] |
### Obtain bottleneck features from another pre-trained CNN. | |
filename = 'bottleneck_features/DogResnet50Data.npz' | |
bottleneck_url = 'https://s3-us-west-1.amazonaws.com/udacity-aind/dog-project/DogResnet50Data.npz' | |
if not exists(filename): | |
urllib.request.urlretrieve(bottleneck_url, filename) | |
bottleneck_features = np.load(filename) | |
train_new = bottleneck_features['train'] |
from keras.layers import Conv2D, MaxPooling2D, GlobalAveragePooling2D | |
from keras.layers import Dropout, Flatten, Dense | |
from keras.models import Sequential | |
model = Sequential() | |
### CNN Architecture for Dog Classifier built from Scracth | |
model.add(Conv2D(16, 2, activation='relu', input_shape=(224,224,3))) | |
model.add(MaxPooling2D(pool_size=(2,2))) |
from keras.applications.resnet50 import ResNet50, preprocess_input, decode_predictions | |
from keras.preprocessing import image | |
from tqdm import tqdm | |
# define ResNet50 model | |
ResNet50_model = ResNet50(weights='imagenet') | |
def path_to_tensor(img_path): | |
# loads RGB image as PIL.Image.Image type | |
img = image.load_img(img_path, target_size=(224, 224)) |
import cv2 | |
import matplotlib.pyplot as plt | |
%matplotlib inline | |
# extract pre-trained face detector | |
face_cascade = cv2.CascadeClassifier('haarcascades/haarcascade_frontalface_alt.xml') | |
def detect_human_face(img): | |
# convert BGR image to grayscale |
I hereby claim:
To claim this, I am signing this object: