-
Notifications
You must be signed in to change notification settings - Fork 6
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
How to convert CK+ dataset to .npy #1
Comments
@fitrialif , Hope these helped. Please reopen if you have any queries. |
hi @arundasan91 , |
Hey @fitrialif , Maybe you're missing something. What you'd want to do is to understand what the function Thanks, |
Hi... it's this how to run this code python utils.py /home/fitrialif/resize
I try run like this but there is no numpy output
…On Nov 29, 2017 4:31 PM, "Arun Das" ***@***.***> wrote:
Hey @fitrialif <https://github.com/fitrialif> , Maybe you're missing
something. What you'd want to do is to understand what the function
filestoTFdata https://github.com/rolanvc/dexpression/blob/master/utils.
py#L4-L33 is doing. You've to call that function with a list of filenames
(absolute paths). The function is well documented. Let me know how it goes.
Thanks,
Arun
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ANibJpb7KEzbHb8crGbk3pAyekDr8yBtks5s7RZdgaJpZM4OLvSE>
.
|
What you are doing is to run the
Also, Line 33 should ring some bells. The function is returning the concatenated array. If you'd want to save the arrays, add a line after Line 38 to save the variables What you need to do is to create a list of filenames say:
You can use Finally, run the code using |
this is my code
import tensorflow as tf
import os
import numpy as np
import cv2
def filestoTFdata(files):
'''
:param files:is a list of filenames of format E$_xxxxxxx.png
representing images of emotions.
The $ is a number from 1..7 representing the emotion (anger, contempt,
disgust, fear, happy, sadness, surprise)
:return: a list of (image) data, and a list of one-hot-arrays
representing emotion labels
'''
images= []
labels = []
for f in files:
# get the filename. extract the E$ to acquire emotion label
fn = os.path.basename(f)
emo = int(fn.split('_')[0][1]) - 1
#create a one-hot vector
onehot = np.array([int(i==emo) for i in range(7)], dtype=np.uint8)
#reshape to be as expected i.e. (1,7)
emo_label = np.reshape(onehot, (1, 7))
# add to list
labels.append(emo_label)
# read the imagee as grayscale
img = cv2.imread(f, cv2.IMREAD_GRAYSCALE)
# expand to that expected
expanded_img = np.expand_dims(np.expand_dims(img,0),3)
# convert to numpy array
image = np.array(expanded_img)
# add to list
images.append(image)
np.save('x.npy',images)
np.save('Y_.npy',labels)
# return lists of images and labels
return images, labels
# test the function above
if __name__== "__main__":
filelist = ['/home/fitrialif/PHDFitri/codeFER/preprocess_ck+/resize/']
images, labels = filestoTFdata(filelist)
i run using python utils.py but i get this error
Traceback (most recent call last):
File "utils.py", line 41, in <module>
images, labels = filestoTFdata(filelist)
File "utils.py", line 18, in filestoTFdata
emo = int(fn.split('_')[0][1]) - 1
IndexError: string index out of range
|
@fitrialif , I strongly suggest you brush up your Python skills and understand the context in which the code is running. Please refer my previous comment for Thanks, |
@fitrialif have you completed this task. I am facing the same problem can you help me?? |
The links to the files are dead. Can I assume that all 5876 are loaded and resized to 224x224x1 for inputting into the network? |
The links that you uploaded is not working, can you update them so we can use the CKP dataset please |
The links are dead, can you update them? Please |
@edgalsanchez , sorry. I checked for the repo, seems it was removed. |
There are many projects which uses CK+ dataset. Unfortunately, since I have used my code in a private project, I cannot share it now. Please search for CK+ dataset in github. |
Load data
X = np.load('CKP_X.npy')
Y = np.load('CKP_Y.npy')
The text was updated successfully, but these errors were encountered: