Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 create_model(): | |
| IMG_SHAPE = (160, 160, 3) | |
| base_model = tf.keras.applications.MobileNetV2(input_shape=IMG_SHAPE, include_top=False, weights="imagenet") | |
| #base_model.summary() | |
| base_model.trainable = False | |
| global_average_layer = tf.keras.layers.GlobalAveragePooling2D()(base_model.output) | |
| prediction_layer = tf.keras.layers.Dense(1, activation='sigmoid')(global_average_layer) | |
| model = tf.keras.models.Model(inputs=base_model.input, outputs=prediction_layer) | |
| #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
| def create_model(): | |
| model = Sequential() | |
| model.add(Conv2D(32, (3, 3), activation='relu', input_shape=(IMG_WIDTH, IMG_HEIGHT, 3))) | |
| model.add(Conv2D(32, (3, 3), activation='relu')) | |
| model.add(BatchNormalization()) | |
| model.add(MaxPooling2D(pool_size=(2, 2))) | |
| model.add(Dropout(0.5)) | |
| model.add(Conv2D(64, (3, 3), 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
| def data_gen(img_names, batch_size, colorspace): | |
| c = 0 | |
| n = img_names #List of training images | |
| random.shuffle(n) | |
| while (True): | |
| img = np.zeros((batch_size, 150, 150, 3)).astype('float') | |
| labels = [] | |
| #initially from 0 to 16, c = 0. |
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
| _URL = 'https://storage.googleapis.com/mledu-datasets/cats_and_dogs_filtered.zip' | |
| path_to_zip = tf.keras.utils.get_file('cats_and_dogs.zip', origin=_URL, extract=True) | |
| PATH = os.path.join(os.path.dirname(path_to_zip), 'cats_and_dogs_filtered') | |
| train_dir = os.path.join(PATH, 'train') | |
| validation_dir = os.path.join(PATH, 'validation') | |
| train_cats_dir = os.path.join(train_dir, 'cats') # directory with our training cat pictures | |
| train_dogs_dir = os.path.join(train_dir, 'dogs') # directory with our training dog pictures | |
| validation_cats_dir = os.path.join(validation_dir, 'cats') # directory with our validation cat pictures | |
| validation_dogs_dir = os.path.join(validation_dir, 'dogs') # directory with our validation dog pictures |
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
| import cv2 | |
| import os | |
| from PIL import Image | |
| import numpy as np | |
| import tensorflow as tf | |
| # assume all variables are defined. That is not the bug. | |
| def create_img(path): | |
| #Function to load,normalize and return image | |
| im = cv2.imread(path) |
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
| import cv2 | |
| import dlib | |
| import numpy as np | |
| def shape_to_np(shape, dtype="int"): | |
| # initialize the list of (x, y)-coordinates | |
| coords = np.zeros((68, 2), dtype=dtype) | |
| # loop over the 68 facial landmarks and convert them | |
| # to a 2-tuple of (x, y)-coordinates | |
| for i in range(0, 68): |