Comments (18)
That's probably because the input array is waiting for an one hot encoding array.
Make sure you set the option --onehot
to yes
when converting the dataset file:
python convert_fer2013_to_images_and_landmarks.py --landmarks=yes --hog=no --jpg=no --onehot=yes --expressions=1,3,4,5,6
from facial-expression-recognition-using-cnn.
Thank you so much !
from facial-expression-recognition-using-cnn.
can you give me more information about the input and output sizes? especially did you change values in the parameters.py file?
from facial-expression-recognition-using-cnn.
I didn't change anything except the save_model_path. Here it is:
class Dataset:
name = 'Fer2013'
train_folder = '../fer2013/fer2013_30000x5/train_set'
validation_folder = '../fer2013/fer2013_30000x5/validation_set'
test_folder = '../fer2013/fer2013_30000x5/test_set'
shape_predictor_path='../fer2013/shape_predictor_68_face_landmarks.dat'
trunc_trainset_to = 500
trunc_validationset_to = 500
trunc_testset_to = -1
class Network:
input_size = 48
output_size = 5
activation = 'relu'
loss = 'categorical_crossentropy'
use_landmarks = True
use_hog_and_landmarks = False
use_batchnorm_after_conv_layers = True
use_batchnorm_after_fully_connected_layers = False
class Hyperparams:
keep_prob = 0.928
learning_rate = 0.001
learning_rate_decay = 0.96
decay_step = 50
optimizer = 'momentum' # {'momentum', 'adam'}
optimizer_param = 0.9 # momentum value for Momentum optimizer, or beta1 value for Adam
class Training:
batch_size = 128
epochs = 1
snapshot_step = 10000
vizualize = True
logs_dir = "logs"
checkpoint_dir = "checkpoints/"
best_checkpoint_path = "checkpoints/best/"
max_checkpoints = 1
checkpoint_frequency = 1.0 # in hours
save_model = True
save_model_path = "saved_model.bin"
class VideoPredictor:
emotions = ["Angry", "Happy", "Sad", "Surprise", "Neutral"]
print_emotions = False
send_by_osc_socket = False
send_by_socket = False
ip = "127.0.0.1" # destination address for sockets and OSC sockets
port = 9003
camera_source = 0
face_detection_classifier = "lbpcascade_frontalface.xml"
show_confidence = False
time_to_wait_between_predictions = 0.5
time_to_wait_to_send_by_socket = 5
def make_dir(folder):
if not os.path.exists(folder):
os.makedirs(folder)
DATASET = Dataset()
NETWORK = Network()
TRAINING = Training()
HYPERPARAMS = Hyperparams()
VIDEO_PREDICTOR = VideoPredictor()
make_dir(TRAINING.logs_dir)
make_dir(TRAINING.checkpoint_dir)
I used your https://github.com/amineHorseman/facial-expression-recognition-svm to generate the train_set, validation_test & test_set files.
from facial-expression-recognition-using-cnn.
It worked.
from facial-expression-recognition-using-cnn.
File "/Desktop/facial-expression-recognition-using-cnn-master/data_loader.py", line 30, in load_data
data_dict['Y'] = data_dict['Y'][0:DATASET.trunc_trainset_to, :]
IndexError: too many indices for array
I am getting error when run, python train.py --train=yes
I used python convert_fer2013_to_images_and_landmarks.py to get train, test and validation set(training,publictest,privatetest)
from facial-expression-recognition-using-cnn.
@husnejahan did you set the argument --onehot to yes?
Try this:
python convert_fer2013_to_images_and_landmarks.py --onehot=yes
from facial-expression-recognition-using-cnn.
Thanks I did and solved. But after training the model I got saved_model.bin.index, how can I get the model in .pbtxt or .bin? need to run ---python predict-from-video.py using saved_model.bin
from facial-expression-recognition-using-cnn.
It appears that there's an error in predict-from-video.py
and predict.py
The current version do not load HOG features from the frame, so the prediction works only if the saved model was trained without the HOG features.
I will try to correct the bug these following days
from facial-expression-recognition-using-cnn.
The bug was solved in the following commit: dbec49f
Please note that sometimes the model is saved as .bin.meta
, if this is the case for you, you have to remove the .meta
extension, or add it to saved_model_path
variable in parameters.py
from facial-expression-recognition-using-cnn.
from facial-expression-recognition-using-cnn.
The last commit 071bfc1 should solve the problem.
Now after training you got the file saved_model.bin
Please note that according to tensorflow's implementation: the save function will create 3 files, each one of them contain different information, and thus if one of the files is deleted the saved_model
can not been loaded
from facial-expression-recognition-using-cnn.
I will close the issue for now, thank you you help
Feel free to reopen the issue if the problem persists
from facial-expression-recognition-using-cnn.
Hey, when I type " python train.py --train=yes " I get the following error.
I haven't changed anything in parameters.py
loading dataset Fer2013...
building model...
WARNING:tensorflow:From /home/dipesh/anaconda3/lib/python3.6/site-packages/tflearn/initializations.py:119: UniformUnitScaling.init (from tensorflow.python.ops.init_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.initializers.variance_scaling instead with distribution=uniform to get equivalent behavior.
WARNING:tensorflow:From /home/dipesh/anaconda3/lib/python3.6/site-packages/tflearn/objectives.py:66: calling reduce_sum (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version.
Instructions for updating:
keep_dims is deprecated, use keepdims instead
2018-09-04 15:16:06.575559: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2018-09-04 15:16:06.640654: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:897] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2018-09-04 15:16:06.640979: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1405] Found device 0 with properties:
name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.7335
pciBusID: 0000:01:00.0
totalMemory: 7.93GiB freeMemory: 7.56GiB
2018-09-04 15:16:06.640993: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1484] Adding visible gpu devices: 0
2018-09-04 15:16:06.803537: I tensorflow/core/common_runtime/gpu/gpu_device.cc:965] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-09-04 15:16:06.803581: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0
2018-09-04 15:16:06.803587: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] 0: N
2018-09-04 15:16:06.803736: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1097] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 7296 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0, compute capability: 6.1)
2018-09-04 15:16:07.744556: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1484] Adding visible gpu devices: 0
2018-09-04 15:16:07.744589: I tensorflow/core/common_runtime/gpu/gpu_device.cc:965] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-09-04 15:16:07.744595: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0
2018-09-04 15:16:07.744599: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] 0: N
2018-09-04 15:16:07.744691: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1097] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 7296 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0, compute capability: 6.1)
start training...
- emotions = 5
- optimizer = 'momentum'
- learning_rate = 0.09632
- learning_rate_decay = 0.6972
- otimizer_param (momentum) = 0.75463
- keep_prob = 0.89383
- epochs = 100
- use landmarks = True
- use hog + landmarks = True
- use hog sliding window + landmarks = True
- use batchnorm after conv = True
- use batchnorm after fc = False
Run id: KNIQA0
Log directory: logs/
Training samples: 28709
Validation samples: 3589
--
Traceback (most recent call last):
File "train.py", line 123, in
train()
File "train.py", line 59, in train
n_epoch=TRAINING.epochs)
File "/home/dipesh/anaconda3/lib/python3.6/site-packages/tflearn/models/dnn.py", line 216, in fit
callbacks=callbacks)
File "/home/dipesh/anaconda3/lib/python3.6/site-packages/tflearn/helpers/trainer.py", line 339, in fit
show_metric)
File "/home/dipesh/anaconda3/lib/python3.6/site-packages/tflearn/helpers/trainer.py", line 818, in _train
feed_batch)
File "/home/dipesh/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 877, in run
run_metadata_ptr)
File "/home/dipesh/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1076, in _run
str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (128, 7) for Tensor 'output/Y:0', which has shape '(?, 5)'
from facial-expression-recognition-using-cnn.
Hello @diycamindia,
Just put output_size = 7
in line 19 on parameters.py
It was fixed to 5 because I used only 5 expressions during my tests, but since you use the whole dataset with 7 expressions, you have to set the output_size
parameter to 7.
N.B: I see that you're using python 3.6, I only tested the code in python 2.7, so let me know if it's working fine for python 3.6 please
from facial-expression-recognition-using-cnn.
Hi. I didn't have any issue while training but when I try to predict the emotion from a picture doing python predict.py --image me.jpg
it's giving the following error
Traceback (most recent call last):
File "predict.py", line 93, in <module>
emotion, confidence = predict(image, model, shape_predictor)
File "predict.py", line 68, in predict
predicted_label = model.predict([tensor_image, features.reshape((1, -1))])
File "C:\Users\ssripat\AppData\Local\Continuum\anaconda3\envs\tf\lib\site-packages\tflearn\models\dnn.py", line 257, in predict
return self.predictor.predict(feed_dict)
File "C:\Users\ssripat\AppData\Local\Continuum\anaconda3\envs\tf\lib\site-packages\tflearn\helpers\evaluator.py", line 69, in predict
return self.session.run(self.tensors[0], feed_dict=feed_dict)
File "C:\Users\ssripat\AppData\Local\Continuum\anaconda3\envs\tf\lib\site-packages\tensorflow\python\client\session.py", line 877, in run
run_metadata_ptr)
File "C:\Users\ssripat\AppData\Local\Continuum\anaconda3\envs\tf\lib\site-packages\tensorflow\python\client\session.py", line 1076, in _run
str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (1, 4744) for Tensor 'input2/X:0', which has shape '(?, 2728)'
I am using python 3.5.6. predict_from_video.py ran without errors though.
from facial-expression-recognition-using-cnn.
Can you provide more details about the parameters you are using?
from facial-expression-recognition-using-cnn.
Hi. I didn't have any issue while training but when I try to predict the emotion from a picture doing
python predict.py --image me.jpg
it's giving the following errorTraceback (most recent call last): File "predict.py", line 93, in <module> emotion, confidence = predict(image, model, shape_predictor) File "predict.py", line 68, in predict predicted_label = model.predict([tensor_image, features.reshape((1, -1))]) File "C:\Users\ssripat\AppData\Local\Continuum\anaconda3\envs\tf\lib\site-packages\tflearn\models\dnn.py", line 257, in predict return self.predictor.predict(feed_dict) File "C:\Users\ssripat\AppData\Local\Continuum\anaconda3\envs\tf\lib\site-packages\tflearn\helpers\evaluator.py", line 69, in predict return self.session.run(self.tensors[0], feed_dict=feed_dict) File "C:\Users\ssripat\AppData\Local\Continuum\anaconda3\envs\tf\lib\site-packages\tensorflow\python\client\session.py", line 877, in run run_metadata_ptr) File "C:\Users\ssripat\AppData\Local\Continuum\anaconda3\envs\tf\lib\site-packages\tensorflow\python\client\session.py", line 1076, in _run str(subfeed_t.get_shape()))) ValueError: Cannot feed value of shape (1, 4744) for Tensor 'input2/X:0', which has shape '(?, 2728)'
I am using python 3.5.6. predict_from_video.py ran without errors though.
got the same
from facial-expression-recognition-using-cnn.
Related Issues (20)
- convert_fer2013_to_images_and_landmarks HOT 2
- sliding window
- TypeError: __call__(): incompatible function arguments. The following argument types are supported:
- Issue in executing optimize_hyperparams.py HOT 2
- about the accuracy HOT 2
- add speech recognition HOT 1
- Landmarks and hog feature HOT 1
- about zerodivisionerror HOT 3
- about the confusion matrix HOT 1
- provide video example HOT 2
- hello,some question about the acc of classification HOT 3
- 3 expression training HOT 2
- A question about convert_fer2013_to_images_and_landmarks.py
- Publication paper HOT 1
- Could not run successfully while using Anaconda
- training accuracy
- error while using predict.py HOT 2
- data_dict['X2'] = np.concatenate((data_dict['X2'], np.load(DATASET.train_folder + '/hog_features.npy')), axis=1) HOT 15
- question about Classification Results
- convert_fer2013_to_images_and_landmarks.py HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from facial-expression-recognition-using-cnn.