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 pandas as pd | |
import matplotlib.pyplot as plt | |
def get_weights(total_data): | |
''' | |
function for initialize random values in the weight vectors for the neural network to be used. | |
uses the no of features to initialize a vector. | |
''' | |
y = np.random.random()*(2.0/np.sqrt(total_data)) |
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 'dart:async'; | |
class Cake {} | |
class Order { | |
String type; | |
Order(this.type); | |
} | |
void main() { |
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 'dart:html'; | |
void main(){ | |
final ButtonElement button = querySelector('button'); | |
button.onClick | |
.timeout( | |
new Duration(seconds:1), |
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 | |
import numpy as np | |
def loadDataFromCSV(path="fer2013/fer2013.csv"): | |
df = pd.read_csv(path) #readeing the csv | |
pixels = df["pixels"].tolist() #extracting the pixels column | |
emotions = pd.get_dummies(df["emotion"]).as_matrix() #extracting emotions and turning them into one-hot labels | |
faces = [] #list for storing faces | |
for pixel_sequence in tqdm(pixels): #main loop for turning the pixel value to images and storing them as numpy arrays | |
face = [int(pixel) for pixel in pixel_sequence.split(" ")] |
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 tensorflow.keras.models import Sequential | |
from tensorflow.keras.layers import Conv2D,MaxPooling2D,BatchNormalization,Dropout,Flatten,Dense | |
num_features = 64 | |
num_labels=7 | |
model = Sequential() | |
model.add(Conv2D(num_features, kernel_size=(3, 3), activation='relu', input_shape=(48, 48, 1), kernel_regularizer=l2(0.01))) | |
model.add(Conv2D(num_features, kernel_size=(3, 3), activation='relu', padding='same')) | |
model.add(BatchNormalization()) | |
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2))) |
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 | |
from tensorflow.keras.models import load_model | |
import numpy as np | |
cascade_file = "haarcascade_frontalface_default.xml" | |
model_file = "fermodel.h5" | |
emotions = ["angry","disgust","scared", "happy", "sad", "surprised","neutral"] | |
face_detection = cv2.CascadeClassifier(cascade_file) | |
emotion_classifier = load_model(model_file, compile=False) |
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 | |
from tensorflow.keras.models import load_model | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import os | |
from imutils import build_montages | |
haar_cascade = "haarcascade_frontalface_default.xml" | |
imgs = os.listdir(path_to_images_dir) | |
model_name = path_to_model |
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
# Making the imports | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import cv2 | |
import os | |
from imutils import build_montages | |
def plot_distribution(paths:list,portion:str): | |
""" | |
This function is used to plot the distribution of train and test images among NORMAL and PNEUMONIA labels |
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
# making the imports | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from tensorflow.keras.layers import Input,Conv2D,MaxPooling2D,Dropout,Flatten,Dense,Activation,BatchNormalization,add | |
from tensorflow.keras.models import Model,Sequential | |
from tensorflow.keras.preprocessing.image import ImageDataGenerator | |
from tensorflow.keras.utils import plot_model | |
from tensorflow.keras.applications.vgg16 import VGG16,preprocess_input | |
import os |
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
# we make our imports | |
from flask import Flask,render_template,redirect,request,send_from_directory | |
from tensorflow.keras.models import load_model | |
import os | |
from PIL import Image | |
import numpy as np | |
# we load the model before starting the app | |
model_file = "model.h5" | |
model = load_model(model_file) |
OlderNewer