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 getLink(number): | |
link='https://www.google.com/search?q='+'geeksforgeeks puzzle '+number | |
response=requests.get(link) | |
ls=[] | |
links=[] | |
try: | |
soup=bs4.BeautifulSoup(response.text,features="html.parser") | |
for tag in soup.find_all('a'): |
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 smtplib, ssl | |
import bs4,webbrowser | |
import requests |
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
model = model_from_json(open("fer.json", "r").read()) #load model | |
model.load_weights('fer.h5') #load weights | |
face_haar_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') | |
camera = cv2.VideoCapture(0) | |
app = Flask(__name__) |
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 flask import Flask, render_template, Response | |
import cv2 | |
import numpy as np | |
from tensorflow.keras.models import model_from_json | |
from tensorflow.keras.preprocessing import image |
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
flask | |
tensorflow | |
opencv-python | |
numpy |
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
fer_json = model1.to_json() | |
with open("fer.json", "w") as json_file: | |
json_file.write(fer_json) | |
model1.save_weights("fer.h5") |
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
x_train=x_train.astype('float32') | |
x_test=x_test.astype('float32') | |
#intializing callbacks | |
early_stopping=keras.callbacks.EarlyStopping(patience=15,restore_best_weights=True) | |
model1.compile(optimizer='Adam',loss='categorical_crossentropy',metrics=['accuracy']) | |
model1.fit(x_train,y_train, | |
batch_size=64, |
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
model1=keras.models.Sequential() | |
# Block-1 | |
model1.add(keras.layers.Conv2D(filters=32, kernel_size=(3,3), padding='same', | |
kernel_initializer='he_normal', | |
activation="elu", | |
input_shape=(48,48,1))) | |
model1.add(keras.layers.BatchNormalization()) | |
model1.add(keras.layers.Conv2D(filters=32, kernel_size=(3,3), padding='same', |
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
#data augmentation | |
x_train=x_train.reshape((x_train.shape[0],48,48,1)) | |
x_test=x_test.reshape((x_test.shape[0],48,48,1)) | |
from keras.preprocessing.image import ImageDataGenerator | |
train_datagen = ImageDataGenerator(rescale=1./255, | |
rotation_range=60, | |
shear_range=0.5, | |
zoom_range=0.5, | |
width_shift_range=0.5, | |
height_shift_range=0.5, |
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
df1 = pd.read_csv("fer2013.csv") #make sure the file is in the root location | |
# Preprocessing | |
x_train=[] | |
x_test=[] | |
y_train=[] | |
y_test=[] | |
for i,row in df1.iterrows(): | |
k=row['pixels'].split(" ") | |
if(row['Usage']=='Training'): |