-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Merged kes-python-flask-app and file-handling branches * Add Kaggle API, File parsing, Calculations, and GeneratePDF Deployed on Heroku from Elizabeth's fork to get the 'analyze the dataset' button to run and return a report in analyse.html. Now, we are merging into Kes's branch to get the analyse.html page working on the heroku app that is meant to be for the project. * Update Installation instructions * Delete data.csv, Add report folder and kaggle info Need to have .kaggle file for the app to have access to the kaggle api Co-authored-by: “Kes <“[email protected]”> Co-authored-by: sakshigupta265 <[email protected]> Co-authored-by: kes cardoso <[email protected]> Co-authored-by: wyang0216 <[email protected]> Co-authored-by: sakshigupta265 <[email protected]>
- Loading branch information
1 parent
c67a362
commit 800c3e6
Showing
24 changed files
with
841 additions
and
163 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
__pycache__ | ||
venv | ||
env.py | ||
.kaggle | ||
.vscode | ||
.DS_Store |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"username":"elizabethcrouther","key":"7a5c2300510b71d5ce544950879b0817"} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import cv2 | ||
|
||
def region_of_interest(faces, img_copy): | ||
|
||
for face in faces: | ||
x,y,w,h = face | ||
offset = 0 | ||
face_section = img_copy[y-offset:y+h+offset, x-offset:x+w+offset] | ||
|
||
return face_section |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
f_name,l_name | ||
Sakshi,Gupta | ||
Elizabeth,Crouther | ||
Kes,Cardoso | ||
William,Yang |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import cv2 | ||
|
||
def draw_found_faces(detected, image, color: tuple): | ||
for (x, y, width, height) in detected: | ||
cv2.rectangle( | ||
image, | ||
(x, y), | ||
(x + width, y + height), | ||
color, | ||
thickness=2 | ||
) | ||
|
||
def detect_faces(img_path): | ||
# creating haar cascade classifier | ||
|
||
faceCascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_frontalface_alt.xml") | ||
|
||
# not in use | ||
profileCascade = cv2.CascadeClassifier(cv2.data.haarcascades + "haarcascade_profileface.xml") | ||
|
||
# reading image | ||
img = cv2.imread(img_path) | ||
|
||
# reducing the size of image to a standard 256x256 image | ||
img = cv2.resize(img,(256,256)) | ||
img_copy = img.copy() | ||
|
||
# converting to gray scale face (makes detection easier :D) | ||
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) | ||
|
||
# Detect faces in the image | ||
front_faces = faceCascade.detectMultiScale( | ||
gray_img, | ||
scaleFactor=1.3, | ||
minNeighbors=5, | ||
) | ||
|
||
profile_faces = profileCascade.detectMultiScale( | ||
gray_img, | ||
scaleFactor=1.3, | ||
minNeighbors=5, | ||
) | ||
|
||
# Filter out profiles | ||
# profiles_not_front_faces = [x for x in profile_faces if x not in front_faces] | ||
|
||
# Draw rectangles around faces on the original, colored image | ||
draw_found_faces(front_faces, img, (0, 255, 0)) # RGB - green | ||
# draw_found_faces(profile_faces, img, (0, 0, 255)) # RGB - red | ||
|
||
# showing image + rectangle | ||
# cv2.imshow('image',img) | ||
|
||
#Wait for any key before image disappears | ||
# cv2.waitKey(0) | ||
# cv2.destroyAllWindows() | ||
|
||
return img_copy,front_faces |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import cv2 | ||
import getColorInformation | ||
from sklearn.cluster import KMeans | ||
import warnings | ||
|
||
|
||
def extractDominantColor(image,number_of_colors,hasThresholding=False): | ||
|
||
# Quick Fix Increase cluster counter to neglect the black(Read Article) | ||
if hasThresholding == True: | ||
number_of_colors +=1 | ||
|
||
# Taking Copy of the image | ||
img = image.copy() | ||
|
||
# Convert Image into RGB Colours Space | ||
img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB) | ||
|
||
# Reshape Image | ||
img = img.reshape((img.shape[0]*img.shape[1]) , 3) | ||
|
||
#Initiate KMeans Object | ||
estimator = KMeans(n_clusters=number_of_colors, random_state=0) | ||
|
||
# Fit the image | ||
with warnings.catch_warnings(): | ||
warnings.simplefilter("ignore") | ||
# cluster_data(data_arr) | ||
estimator.fit(img) | ||
|
||
# Get Colour Information | ||
colorInformation = getColorInformation.getColorInformation(estimator.labels_,estimator.cluster_centers_,hasThresholding) | ||
return colorInformation |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import cv2 | ||
import numpy as np | ||
|
||
def extractSkin(image): | ||
# Taking a copy of the image | ||
img = image.copy() | ||
# Converting from BGR Colours Space to HSV | ||
img = cv2.cvtColor(img,cv2.COLOR_BGR2HSV) | ||
|
||
# Defining HSV Threadholds | ||
lower_threshold = np.array([0, 48, 80], dtype=np.uint8) | ||
upper_threshold = np.array([20, 255, 255], dtype=np.uint8) | ||
|
||
# Single Channel mask,denoting presence of colours in the about threshold | ||
skinMask = cv2.inRange(img,lower_threshold,upper_threshold) | ||
|
||
# Cleaning up mask using Gaussian Filter | ||
skinMask = cv2.GaussianBlur(skinMask,(3,3),0) | ||
|
||
# Extracting skin from the threshold mask | ||
skin = cv2.bitwise_and(img,img,mask=skinMask) | ||
|
||
# Return the Skin image | ||
return cv2.cvtColor(skin,cv2.COLOR_HSV2BGR) | ||
|
||
def removeBlack(estimator_labels, estimator_cluster): | ||
|
||
|
||
# Check for black | ||
hasBlack = False | ||
|
||
# Get the total number of occurance for each color | ||
occurance_counter = Counter(estimator_labels) | ||
|
||
|
||
# Quick lambda function to compare to lists | ||
compare = lambda x, y: Counter(x) == Counter(y) | ||
|
||
# Loop through the most common occuring color | ||
for x in occurance_counter.most_common(len(estimator_cluster)): | ||
|
||
# Quick List comprehension to convert each of RBG Numbers to int | ||
color = [int(i) for i in estimator_cluster[x[0]].tolist() ] | ||
|
||
|
||
|
||
# Check if the color is [0,0,0] that if it is black | ||
if compare(color , [0,0,0]) == True: | ||
# delete the occurance | ||
del occurance_counter[x[0]] | ||
# remove the cluster | ||
hasBlack = True | ||
estimator_cluster = np.delete(estimator_cluster,x[0],0) | ||
break | ||
|
||
|
||
return (occurance_counter,estimator_cluster,hasBlack) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import glob | ||
import os | ||
import cv2 | ||
import main | ||
import sys | ||
|
||
def getPath(folder): | ||
|
||
if sys.platform.startswith('darwin') or sys.platform.startswith('linux') : # - elizabeth - my mac wasn't recognizing the regex in the elif 'win32' code | ||
my_path = os.getcwd()+'/dataFiles/'+folder+'/' | ||
files_jpg = glob.glob(my_path + '*.jpg' , recursive=True) | ||
files_jpeg = glob.glob(my_path + '*.jpeg' , recursive=True) | ||
files_png = glob.glob(my_path + '*.png' , recursive=True) | ||
|
||
elif sys.platform.startswith('win32'): | ||
my_path = os.getcwd() | ||
files_jpg = glob.glob(my_path + '\\dataFiles\\**\\*.jpg' , recursive=True) | ||
files_jpeg = glob.glob(my_path + '\\dataFiles\\**\\*.jpeg' , recursive=True) | ||
files_png = glob.glob(my_path + '\\dataFiles\\**\\*.png' , recursive=True) | ||
|
||
files = files_jpeg + files_jpg + files_png | ||
l = len(files) | ||
# files = sorted(files) | ||
|
||
# print(files) | ||
# print(len(files)) | ||
|
||
return files, l | ||
|
||
# For debugging without running the whole app | ||
|
||
# my_path = os.getcwd() | ||
# files_jpg = glob.glob(my_path + '\\dataFiles\\**\\*.jpg' , recursive=True) | ||
# files_jpeg = glob.glob(my_path + '\\dataFiles\\**\\*.jpeg' , recursive=True) | ||
# files_png = glob.glob(my_path + '\\dataFiles\\**\\*.png' , recursive=True) | ||
|
||
# files = files_jpeg + files_jpg + files_png | ||
# l = len(files) | ||
|
||
# main.readImage(files, l) |
Oops, something went wrong.