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
!pip install --upgrade google-cloud-vision |
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
def detect_face(face_file, max_results=4): | |
client = vision.ImageAnnotatorClient() | |
content = face_file.read() | |
image = types.Image(content=content) | |
return client.face_detection(image=image, max_results=max_results).face_annotations | |
def crop_faces(image_to_crop, cropped_photos_dir): | |
with open(image_to_crop, 'rb') as image: | |
faces = detect_face(image, 8) |
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
tf.keras.layers.Dense(1024, activation='relu'), | |
tf.keras.layers.Dropout(0.75), | |
tf.keras.layers.Dense(1, activation='sigmoid') ]) |
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
from tensorflow.keras.applications.resnet50 import ResNet50, preprocess_input | |
from tensorflow.keras.layers import Dense, Activation, Flatten, Dropout | |
from tensorflow.keras.models import Sequential, Model | |
HEIGHT = 300 | |
WIDTH = 300 | |
base_model = ResNet50(weights='imagenet', | |
include_top=False, | |
input_shape=(HEIGHT, WIDTH, 3)) |
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
from google.colab import drive | |
drive.mount('/content/drive/') |
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
from tensorflow.keras.preprocessing.image import ImageDataGenerator | |
train_datagen = ImageDataGenerator(rescale=1/255) | |
train_generator = train_datagen.flow_from_directory( | |
'/content/drive/My Drive/Training/', | |
target_size=(300, 300), | |
batch_size=10, | |
class_mode='binary') |
NewerOlder