Skip to content

Instantly share code, notes, and snippets.

View anuj2110's full-sized avatar
🎯
Focusing

ANUJ TREHAN anuj2110

🎯
Focusing
  • India
View GitHub Profile
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))
import 'dart:async';
class Cake {}
class Order {
String type;
Order(this.type);
}
void main() {
import 'dart:html';
void main(){
final ButtonElement button = querySelector('button');
button.onClick
.timeout(
new Duration(seconds:1),
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(" ")]
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)))
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)
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
# 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
# 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
# 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)