- Notifications
You must be signed in to change notification settings - Fork1
dhchenx/DeepFaceEmotion
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A revised DeepFace to have callback function for saving emotion inside program
Although theDeepFace project has an amazing abilities to retrieve facial attriburtes in realtime video analysis, the library is not able to provide a callback function so developers can obtain the identified attributes inside their codes. This limits the developer to write automated programs for data mining, for example, automatically retrive the attributes and save the attributes to a csv plain text file.
Hence, I revised thedeepface
class in the library to fulfile the needs.
Replace the attacheddeepface.py
andcommons/realtime.py
inside the installed deepface lib in python package directory and perform the below example code:
fromdeepfaceimportDeepFacecount=0# this function ensures we can write codes to save the timestamp-based facial attributes during processing videodefcall_back_func(emotions,age,gender,ts):globalcountcount+=1print(emotions)print(age)print(gender)print()DeepFace.stream(# db_path="../doctor_images",# source=0,source="video/test2.mp4",enable_face_recognition=False,call_back_func=call_back_func,time_threshold=2)# pass call_back_func to the stream function# do some work based on the retrieved attributes in time seriesprint("Total Emotions Identification: ",count)
Say thanks to theDeepFace project.
This revised feature may be unnecessary if the deepface library team adds new features to their library.