Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spelling mistakes and deprecated errors fixed #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
12 changes: 7 additions & 5 deletions convert_fer2013_to_images_and_landmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import argparse
import errno
import scipy.misc
import imageio
import dlib
import cv2

Expand Down Expand Up @@ -93,7 +94,7 @@ def sliding_hog_windows(image):
for x in range(0, image_width, window_step):
window = image[y:y+window_size, x:x+window_size]
hog_windows.extend(hog(window, orientations=8, pixels_per_cell=(8, 8),
cells_per_block=(1, 1), visualise=False))
cells_per_block=(1, 1), visualize=False))
return hog_windows

print( "importing csv file")
Expand Down Expand Up @@ -126,24 +127,25 @@ def sliding_hog_windows(image):
try:
if labels[i] in SELECTED_LABELS and nb_images_per_label[get_new_label(labels[i])] < IMAGES_PER_LABEL:
image = np.fromstring(samples[i], dtype=int, sep=" ").reshape((image_height, image_width))
image = image.astype(np.uint8)
images.append(image)
if SAVE_IMAGES:
scipy.misc.imsave(category + '/' + str(i) + '.jpg', image)
imageio.imsave(category + '/' + str(i) + '.jpg', image)
if GET_HOG_WINDOWS_FEATURES:
features = sliding_hog_windows(image)
f, hog_image = hog(image, orientations=8, pixels_per_cell=(16, 16),
cells_per_block=(1, 1), visualise=True)
cells_per_block=(1, 1), visualize=True)
hog_features.append(features)
if GET_HOG_IMAGES:
hog_images.append(hog_image)
elif GET_HOG_FEATURES:
features, hog_image = hog(image, orientations=8, pixels_per_cell=(16, 16),
cells_per_block=(1, 1), visualise=True)
cells_per_block=(1, 1), visualize=True)
hog_features.append(features)
if GET_HOG_IMAGES:
hog_images.append(hog_image)
if GET_LANDMARKS:
scipy.misc.imsave('temp.jpg', image)
imageio.imsave('temp.jpg', image)
image2 = cv2.imread('temp.jpg')
face_rects = [dlib.rectangle(left=1, top=1, right=47, bottom=47)]
face_landmarks = get_landmarks(image2, face_rects)
Expand Down
4 changes: 2 additions & 2 deletions predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def sliding_hog_windows(image):
for x in range(0, NETWORK.input_size, window_step):
window = image[y:y+window_size, x:x+window_size]
hog_windows.extend(hog(window, orientations=8, pixels_per_cell=(8, 8),
cells_per_block=(1, 1), visualise=False))
cells_per_block=(1, 1), visualize=False))
return hog_windows

def predict(image, model, shape_predictor=None):
Expand All @@ -60,7 +60,7 @@ def predict(image, model, shape_predictor=None):
features = np.concatenate((face_landmarks, hog_features))
else:
hog_features, _ = hog(image, orientations=8, pixels_per_cell=(16, 16),
cells_per_block=(1, 1), visualise=True)
cells_per_block=(1, 1), visualize=True)
hog_features = np.asarray(hog_features)
face_landmarks = face_landmarks.flatten()
features = np.concatenate((face_landmarks, hog_features))
Expand Down