In this post we will use the OpenCV library for facial recognition. Here is an example using my webcam as an input:
The best part is that it can be done using less than 20 lines of code:
| from sklearn.datasets import make_regression | |
| from sklearn.metrics import r2_score | |
| import matplotlib.pyplot as plt | |
| #%matplotlib inline | |
| # Generate toy data | |
| X, y, w_true = make_regression(n_samples=20, n_features=1, random_state=0, noise=1.0, coef=True) | |
| w_bad = 0.5*w_true | |
| w_verybad = -0.3*w_true | 
| import matplotlib.pyplot as plt | |
| import keras.backend as K | |
| from keras.callbacks import Callback | |
| class LRFinder(Callback): | |
| ''' | |
| A simple callback for finding the optimal learning rate range for your model + dataset. | |
| from keras.callbacks import Callback | |
| import keras.backend as K | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| class LRFinder(Callback): | |
| """ | |
| Up-to date version: https://github.com/WittmannF/LRFinder | |
| Example of usage: | |
| from keras.models import Sequential | 
| from selenium import webdriver | |
| from PIL import Image | |
| from io import BytesIO | |
| def take_screenshot(element, driver, filename='screenshot.png'): | |
| """ | |
| Source: https://stackoverflow.com/questions/15018372/how-to-take-partial-screenshot-with-selenium-webdriver-in-python | |
| """ | |
| location = element.location_once_scrolled_into_view | |
| size = element.size | 
| ## Imports | |
| from ashrae_utils import reduce_mem_usage, CyclicLR, LRFinder | |
| import numpy as np # linear algebra | |
| import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) | |
| import math | |
| import tqdm | |
| import gc | |
| from sklearn.linear_model import RidgeCV | |
| import seaborn as sns | 
| print('hello world') | 
| import re | |
| PATTERN = '(.*), (.*) - (.*): [bB]om dia' | |
| db = re.findall(PATTERN, txt) |