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 tensorflow as tf | |
import glob | |
import imageio | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import os | |
import PIL | |
from tensorflow.keras import layers | |
import time |
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
# Using a circular mask as the blur area to automatically blur the face in a video, giving it a more cleaner look. | |
# We're using OpenCV, and Dlib with Python. | |
# See tutorial here: https://youtu.be/1p1lUyLGB2E | |
import numpy as np | |
import cv2 | |
import dlib | |
video_capture = cv2.VideoCapture(1) | |
detector = dlib.get_frontal_face_detector() |
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
# Blur Your Face Automatically with OpenCV and Dlib | |
# See tutorial at https://www.youtube.com/watch?v=QKggnWdCTNY | |
import numpy as np | |
import cv2 | |
import dlib | |
video_capture = cv2.VideoCapture(1) | |
detector = dlib.get_frontal_face_detector() |
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 numpy as np | |
from keras.preprocessing.image import ImageDataGenerator, img_to_array, load_img | |
from keras.models import Sequential, Model | |
from keras.layers import Dropout, Flatten, Dense, GlobalAveragePooling2D, Input | |
from keras.applications.inception_v3 import InceptionV3 | |
from keras.utils.np_utils import to_categorical | |
from keras import optimizers | |
from keras.callbacks import EarlyStopping, ModelCheckpoint | |
from datetime import datetime, timedelta | |
import matplotlib.pyplot as plt |
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 numpy as np | |
import cv2 | |
import dlib | |
from scipy.spatial import distance as dist | |
from scipy.spatial import ConvexHull | |
PREDICTOR_PATH = "../data/dlib_models/shape_predictor_68_face_landmarks.dat" | |
FULL_POINTS = list(range(0, 68)) | |
FACE_POINTS = list(range(17, 68)) |
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
''' | |
Using Correlation Trackers in Dlib, you can track any object in a video stream without needing to train a custom object detector. | |
Check out the tutorial at: http://www.codesofinterest.com/2018/02/track-any-object-in-video-with-dlib.html | |
''' | |
import numpy as np | |
import cv2 | |
import dlib | |
# this variable will hold the coordinates of the mouse click events. | |
mousePoints = [] |
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 keras.applications.resnet50 import ResNet50 | |
from keras.preprocessing import image | |
from keras.applications.resnet50 import preprocess_input, decode_predictions | |
import numpy as np | |
model = ResNet50(weights='imagenet') | |
img_path = 'Data/Jellyfish.jpg' | |
img = image.load_img(img_path, target_size=(224, 224)) | |
x = image.img_to_array(img) |
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 keras.applications.vgg16 import VGG16 | |
from keras.preprocessing import image | |
from keras.applications.vgg16 import preprocess_input, decode_predictions | |
import numpy as np | |
model = VGG16(weights='imagenet') | |
img_path = 'Data/Jellyfish.jpg' | |
img = image.load_img(img_path, target_size=(224, 224)) | |
img_data = image.img_to_array(img) |
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 keras.models import Sequential | |
from keras.layers.core import Flatten, Dense, Dropout | |
from keras.layers.convolutional import Conv2D, MaxPooling2D, ZeroPadding2D | |
from keras.optimizers import SGD | |
import numpy as np | |
def VGG_16(weights_path=None): | |
input_shape=(224,224,3) | |
model = Sequential() |
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
# How to use | |
# | |
# Train the model and save the model weights | |
# python lenet_mnist_keras.py --train-model 1 --save-trained 1 | |
# | |
# Train the model and save the model wights to a give directory | |
# python lenet_mnist_keras.py --train-model 1 --save-trained 1 --weights data/lenet_weights.hdf5 | |
# | |
# Evaluate the model from pre-trained model wights | |
# python lenet_mnist_keras.py |
NewerOlder