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 numpy as np | |
| #path to classifiers | |
| path = '/Users/mitchellkrieger/opt/anaconda3/envs/learn-env/share/opencv4/haarcascades/' | |
| #get image classifiers | |
| face_cascade = cv2.CascadeClassifier(path +'haarcascade_frontalface_default.xml') | |
| eye_cascade = cv2.CascadeClassifier(path +'haarcascade_eye.xml') |
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
| #read image | |
| img = cv2.imread('people.jpg') | |
| #convert to gray | |
| gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) | |
| #detect faces | |
| faces = face_cascade.detectMultiScale(gray, 1.3, 5) | |
| #for each face |
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 numpy as np | |
| path = '/Users/YOUR/PATH/HERE/share/opencv4/haarcascades/' | |
| #get facial classifiers | |
| face_cascade = cv2.CascadeClassifier(path +'haarcascade_frontalface_default.xml') | |
| eye_cascade = cv2.CascadeClassifier(path +'haarcascade_eye.xml') | |
| #read images |
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
| for (x,y,w,h) in faces: | |
| #retangle for testing purposes | |
| #img = cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2) | |
| #coordinates of face region | |
| face_w = w | |
| face_h = h | |
| face_x1 = x | |
| face_x2 = face_x1 + face_w | |
| face_y1 = y |
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 numpy as np | |
| path = '/Users/YOUR/PATH/HERE/share/opencv4/haarcascades/' | |
| #get facial classifiers | |
| face_cascade = cv2.CascadeClassifier(path +'haarcascade_frontalface_default.xml') | |
| eye_cascade = cv2.CascadeClassifier(path +'haarcascade_eye.xml') | |
| #read images |
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 pandas as pd | |
| # read data from NY times | |
| df = pd.read_csv("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us.csv") | |
| # engineer new cases | |
| df['new_cases'] = df.cases - df.cases.shift().fillna(0) | |
| # create pandas time series | |
| df.date = pd.to_datetime(df.date) |
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 fbprophet import Prophet | |
| # instantiate the model and fit the timeseries | |
| prophet = Prophet() | |
| prophet.fit(ts) | |
| # create a future data frame | |
| future = prophet.make_future_dataframe(periods=25) | |
| forecast = prophet.predict(future) |
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 fbprophet.plot import add_changepoints_to_plot | |
| a = add_changepoints_to_plot(fig.gca(),m,forcast) | |
| fig |
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
| # instantiate the model and fit the timeseries | |
| prophet = Prophet(weekly_seasonality=False, changepoint_range=1,changepoint_prior_scale=0.75) | |
| prophet.fit(ts) | |
| # create a future data frame | |
| future = prophet.make_future_dataframe(periods=25) | |
| forecast = prophet.predict(future) | |
| # display the most critical output columns from the forecast | |
| forecast[['ds','yhat','yhat_lower','yhat_upper']].head() |
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 dash | |
| import dash_bootstrap_components as dbc | |
| #Instantiates the Dash app and identify the server | |
| app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP]) | |
| server = app.server |
OlderNewer