Skip to content

Instantly share code, notes, and snippets.

View WittmannF's full-sized avatar
🇧🇷

Fernando Marcos Wittmann WittmannF

🇧🇷
View GitHub Profile

Face Recognition in Python with the OpenCV Library

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:

## 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
@WittmannF
WittmannF / bi-wp-familia.ipynb
Last active June 1, 2020 02:19
BI-wp-familia.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@WittmannF
WittmannF / take-element-screenshot-selenium.py
Last active August 22, 2022 04:14
Function for taking a screenshot of an element using selenium
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
@WittmannF
WittmannF / bi-wp-familia.ipynb
Created January 10, 2020 20:02
BI-wp-familia.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@WittmannF
WittmannF / lr_finder_keras.py
Last active June 3, 2022 12:13
Learning Rate Finder as a Keras Callback
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
@WittmannF
WittmannF / lr_finder.py
Last active May 30, 2019 13:38 — forked from jeremyjordan/lr_finder.py
Keras Callback for finding the optimal range of learning rates
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.
@WittmannF
WittmannF / compare_r2.py
Created January 23, 2019 18:25
Very simple code for comparing different R2 scores
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
@WittmannF
WittmannF / exemplo_bizelli.py
Last active November 21, 2018 22:07
Rename subtitles from Udacity class. Code by Bizelli.
import os
def rename_dir(path,sufix,extension_searched):
for file_name in os.listdir(path):
file_name_without_ext = os.path.splitext(file_name)[0]
extension = os.path.splitext(file_name)[1]
if extension == extension_searched:
if file_name_without_ext.rfind(sufix) > 0:
new_file_name = file_name[:file_name_without_ext.rfind(sufix)] + extension_searched
os.rename(os.path.join(path,file_name),os.path.join(path,new_file_name))
@WittmannF
WittmannF / whatsapp_api.py
Created November 14, 2018 21:34
WhatsApp API Selenium
"""
### Implemented Methods
- Get contacts from a selected group
### Requires
- Selenium: `pip install selenium`
- ChromeDriver: http://chromedriver.chromium.org/
- After downloading chromedriver, make sure to add in a folder accessible from the PATH
### Example of Usage: