Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Accuracy and loss graphics in Emotion Recognition

https://github.com/atulapra/Emotion-detection

I build the code above and I’m predicting emotions from faces..
An accuracy and loss graphics were shared in the "Read me" section of the code.

graph

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I don’t know how this graph was created.
I found the following link on stackoverflow how graph drawing:
Keras – Plot training, validation and test set accuracy

best answer is show :

history = model1.fit(train_x, train_y,validation_split = 0.1, epochs=50, batch_size=4)

I couldn’t figure out where will they come values for trainx trainy according to the github code.

dataset_prepare.py here separates data into train and test. We’ll take it from here I think.. but what will we take?

How to draw such loss and accuracy graphs?

Where will I add to code in emotion.py?

if I add the code where the model is predicted there is a for loop there and it will result in countless graphs.

>Solution :

Quickly looking at the repo you provided, line 98 in emotion.py is plot_model_history(model_info). The function is defined starting at line 20 in the same file:

def plot_model_history(model_history):
    """
    Plot Accuracy and Loss curves given the model_history
    """
    fig, axs = plt.subplots(1,2,figsize=(15,5))
    # summarize history for accuracy
    axs[0].plot(range(1,len(model_history.history['accuracy'])+1),model_history.history['accuracy'])
    axs[0].plot(range(1,len(model_history.history['val_accuracy'])+1),model_history.history['val_accuracy'])
    axs[0].set_title('Model Accuracy')
    axs[0].set_ylabel('Accuracy')
    axs[0].set_xlabel('Epoch')
    axs[0].set_xticks(np.arange(1,len(model_history.history['accuracy'])+1),len(model_history.history['accuracy'])/10)
    axs[0].legend(['train', 'val'], loc='best')
    # summarize history for loss
    axs[1].plot(range(1,len(model_history.history['loss'])+1),model_history.history['loss'])
    axs[1].plot(range(1,len(model_history.history['val_loss'])+1),model_history.history['val_loss'])
    axs[1].set_title('Model Loss')
    axs[1].set_ylabel('Loss')
    axs[1].set_xlabel('Epoch')
    axs[1].set_xticks(np.arange(1,len(model_history.history['loss'])+1),len(model_history.history['loss'])/10)
    axs[1].legend(['train', 'val'], loc='best')
    fig.savefig('plot.png')
    plt.show()

So training the model using python emotions.py --mode train should plot, and write the curves to plot.png.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading