#Comment
import cv2
import os
from deepface import DeepFace
path = r'C:\Users\hwojc\Desktop\Diplomka\01 Datasety\AffectNet\Validation\surprise\augmented2'

imgCount = 0

emCounts = {
    "Angry" : 0,
    "Disgust" : 0,
    "Fear" : 0,
    "Happy" : 0,
    "Neutral" : 0,
    "Sad" : 0,
    "Surprise" : 0
    } 

for images in os.listdir(path):
    if(images.endswith(".jpg") or images.endswith(".png")):
        path2 = os.path.join(path,images)
        print(path2)
        img = cv2.imread(path2)
        result = DeepFace.analyze(img, actions = ['emotion'], enforce_detection= False)

        dominantEmotion = result['dominant_emotion']
        dominantEmotionPct = result['emotion'][result['dominant_emotion']]
        print(dominantEmotion, ":",  dominantEmotionPct, "%")
        
        #if(dominantEmotionPct > 90.0):
        emCounts[dominantEmotion] += 1
        imgCount += 1
            




print(emCounts)
cv2.destroyAllWindows()


