Тёмный

Train your own Neural Network for Facial expression recognition | TensorFlow, CNN, Keras, tutorial 

When Maths Meet Coding
Подписаться 14 тыс.
Просмотров 26 тыс.
50% 1

If you like the video, please subscribe to the channel by using the below link
tinyurl.com/1w5i9nnu
In this video, I have explained how you can train a neural network for facial expression detection. we have trained tensorflow here for model tarining
Link to download the file
drive.google.com/file/d/1-lto...
Here is the script to extract the image dataset
##########################
import tarfile
fname = 'fer2013.tar.gz'
if fname.endswith("tar.gz"):
tar = tarfile.open(fname, "r:gz")
tar.extractall()
tar.close()
elif fname.endswith("tar"):
tar = tarfile.open(fname, "r:")
tar.extractall()
tar.close()
###########################
Data Dictionary
######################
label_to_text = {0:'anger', 1:'disgust', 2:'fear', 3:'happiness', 4: 'sadness', 5: 'surprise', 6: 'neutral'}
######################
Visulize sample dataset
######################
fig = pyplot.figure(1, (14, 14))
k = 0
for label in sorted(df.emotion.unique()):
for j in range(3):
px = df[df.emotion==label].pixels.iloc[k]
px = np.array(px.split(' ')).reshape(48, 48).astype('float32')
k += 1
ax = pyplot.subplot(7, 7, k)
ax.imshow(px)
ax.set_xticks([])
ax.set_yticks([])
ax.set_title(label_to_text[label])
pyplot.tight_layout()
########################
callback and checkpoint code
#######################################
file_name = 'best_model.h5'
checkpoint_path= os.path.join('checkpoint',file_name)
call_back = tf.keras.callbacks.ModelCheckpoint(filepath=checkpoint_path,
monitor='val_accuracy',
verbose=1,
save_freq='epoch',
save_best_only=True,
save_weights_only=False,
mode='max')
##############################################
Model build code
basemodel = tf.keras.models.Sequential([tf.keras.layers.Conv2D(32,(3,3),activation='relu',input_shape = (48,48,1)),
tf.keras.layers.MaxPool2D(2,2),
#
tf.keras.layers.Conv2D(64,(3,3),activation='relu',input_shape = (48,48,1)),
tf.keras.layers.MaxPool2D(2,2),
#
tf.keras.layers.Conv2D(128,(3,3),activation='relu),
tf.keras.layers.MaxPool2D(2,2),
#
tf.keras.layers.Conv2D(256,(3,3),activation='relu'),
tf.keras.layers.MaxPool2D(2,2),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(1000,activation='relu'),
tf.keras.layers.Dense(7,activation = 'softmax')
])
Dataset Developed by
"Challenges in Representation Learning: A report on three machine learning
contests." I Goodfellow, D Erhan, PL Carrier, A Courville, M Mirza, B
Hamner, W Cukierski, Y Tang, DH Lee, Y Zhou, C Ramaiah, F Feng, R Li,
X Wang, D Athanasakis, J Shawe-Taylor, M Milakov, J Park, R Ionescu,
M Popescu, C Grozea, J Bergstra, J Xie, L Romaszko, B Xu, Z Chuang, and
Y. Bengio. arXiv 2013.
See fer2013.bib for a bibtex entry.

Опубликовано:

 

13 фев 2021

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 44   
@satishchhatpar
@satishchhatpar 3 года назад
Thank you for sharing Jay. Very simple and easy to understand.
@whenmathsmeetcoding1836
@whenmathsmeetcoding1836 3 года назад
Glad it was helpful!
@lordyhbp
@lordyhbp 2 года назад
Thank you so much for this video.
@user-nl1iu1mb2o
@user-nl1iu1mb2o 3 года назад
thank you for sharing this file
@sheemakhan4738
@sheemakhan4738 2 года назад
Thank you soo so so much!!!... Can u plz make a video on how gabor and HOG features can be incorporated into this algorithm...
@jonatapaulino
@jonatapaulino 2 года назад
Deserves the like. Thanks, that's what I was looking for. Is there any way you can make the code available for studies? If I may, another question would be: What convolutional network architecture are you using in this video? Thanks.
@andreeapopescu8234
@andreeapopescu8234 3 года назад
Hi! Why am I getting this error 'ModelCheckpoint' object is not iterable when trying to run the basemodel.fit part of the code?
@deepakdadlani9284
@deepakdadlani9284 3 года назад
Can you make the video dog and cat emotion recognizer 🤔 any kind of datasets available for that?
@sheemakhan459
@sheemakhan459 2 года назад
I need to apply genetic algorithm to this code...does anyone know how that can be done..specifically for this code...there is already an optimizer for gradient decent used in this...i just have to apply different optimization algo like pso and simulated annealing etc to this code
@eswaraprasad772
@eswaraprasad772 2 года назад
Sir i am getting just maximum 58 validation accuracy but you got 78 how sir? And I am getting Actual label is (label_to_text [y_test [k]]) but you got emotions name how sir?
@derirh
@derirh Год назад
why do I try but error like this ValueError: Data cardinality is ambiguous: x sizes: 29068 y sizes: 3589 Make sure all arrays contain the same number of samples.
@ibrahimabah6063
@ibrahimabah6063 3 года назад
Hello sir, thank you for sharing. But I tried exactly the way you did but the validation accuracy I got is just 63% and the model is overfitting.
@pietrodispaldro3490
@pietrodispaldro3490 Год назад
How i can use this algorithm wit my dataset? What is the line to change?
@skarbazalam4284
@skarbazalam4284 Год назад
same thing we need to do with test dataset ?
@ashvinpidaparti3942
@ashvinpidaparti3942 Год назад
75+% is state of the art for this dataset. Even the most rigorous models have achieved a maximum of 75.2% accuracy. How did you train your network?
@itzzmohib1461
@itzzmohib1461 2 года назад
How Can I Check Any Picture Other Than The Dataset Using The Code
@sudheerbabu3050
@sudheerbabu3050 2 года назад
img_array = df.pixels.apply(lambda x : np.array(x.split(' ')).reshape(48,48).astype('float32')) ValueError: Cannot reshape array of size 1261 into shape(48,48)
@anantvignesh9721
@anantvignesh9721 3 года назад
A nice example for a beginner. Correct me if I'm wrong, but I think your model is clearly overfitting as the training accuracy quickly reaches 98% while your validation accuracy still remains at 78%. Usually, a +/-5% difference between training and validation accuracy is fine, but this is very high. That being said, FER 2013 is one of the most complicated datasets for emotion recognition. This dataset is highly imbalanced and the best papers around the world have only reached accuracies of 73%-75%. So, your model reaching 78% with a fairly shallow network seems very unlikely.
@Shadowwalker297
@Shadowwalker297 3 года назад
How to prevent that from happening, i try use his code and examples and i get overfitting
@balakrishnaperala794
@balakrishnaperala794 2 года назад
shall i use another dataset for facial expression recognition then? can u please help me
@printholamundo955
@printholamundo955 8 месяцев назад
​@@balakrishnaperala794 you can used CK+ or JAFFE for complement your training after applied FER2013 to model. Most papers used this strategy.
@muhammadshayan8794
@muhammadshayan8794 2 года назад
can you train image dataset
@sadaffnazz725
@sadaffnazz725 8 месяцев назад
sir can you give complete code which you ate in this video? Sir. I need this code
@kienyiep5437
@kienyiep5437 2 года назад
just wonder how you convert the image into the string of pixels, is there any tutorial link to teach this?
@areeb3663
@areeb3663 2 года назад
yes same
@manukumar4063
@manukumar4063 2 года назад
Bhai ye wala project mila satkh hai kya source code k saath
@fekeduna4819
@fekeduna4819 3 года назад
how to train an image neural network using matlab code
@Soedmaelk
@Soedmaelk 2 года назад
Thank you so much for this video. However, doing as you did (even with the new model, validation split of 0.2, and 50 epochs), I could not get val_acc of more than 0.57864. You received 0.78 or something. Can't figure out why. Maybe it would be nice if viewers could see the source code. But thanks again - Helped my very much!
@Raysworkshop
@Raysworkshop 2 года назад
yep I got the same, around 0.59 for the val_accuracy. can't figure out how to improve it
@narendranathjagarlamudi3191
@narendranathjagarlamudi3191 2 года назад
same here, i dont understand how he got 78 percent after changing to GPU.
@sudheerbabu3050
@sudheerbabu3050 2 года назад
I am getting an error. ValueError: cannot reshape array of size 1261 into shape (48,48)
@christianbj12
@christianbj12 2 года назад
Your image is the wrong size. It is not 48 by 48 pixels, which should equal 2304
@rubykhatri5908
@rubykhatri5908 3 года назад
how to find confusion matrix after this?
@kuragayalavasanth9464
@kuragayalavasanth9464 2 года назад
Yes needed it too
@rickyvonicky4371
@rickyvonicky4371 2 года назад
trump angry bill gates happy.... rest asure the nn between your brain is well trained
@manukumar4063
@manukumar4063 2 года назад
Bhai ye wala project mila satkh hai kya source code k saath
Далее
Build a Deep CNN Image Classifier with ANY Images
1:25:05
Is it impossible to cut off so much?💀🍗
00:14
Просмотров 4,3 млн
Transformer Neural Networks Derived from Scratch
18:08
Просмотров 129 тыс.
Real - time emotion detection using python
13:06
Просмотров 18 тыс.
Variational Autoencoders
15:05
Просмотров 484 тыс.
I Built a Neural Network from Scratch
9:15
Просмотров 167 тыс.
TensorFlow in 100 Seconds
2:39
Просмотров 912 тыс.
The Essential Main Ideas of Neural Networks
18:54
Просмотров 901 тыс.
Convolutional Neural Networks from Scratch | In Depth
12:56
Is it impossible to cut off so much?💀🍗
00:14
Просмотров 4,3 млн