Fixes:#2 Add DeepFace-based emotion detection with YouTube music recommendation #39
Fixes:#2 Add DeepFace-based emotion detection with YouTube music recommendation #39vanixyz wants to merge 7 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
SGCODEX
left a comment
There was a problem hiding this comment.
Heyy, @vanixyz!! Great work, The PR is well explained and code looks good. Please attach some screenshots to show how this is working and also if you can so please compare and tell here how is this library better or more efficient than the hdf model file way. Also can maybe test both against some general benchmarks and share those results too.
|
Heyy @SGCODEX ,I have made the neccesary changes in the PR kindly check and let me know if I need to commit the benchmarking code too for both the files 😊 . |
|
Heyy @vanixyz , That's actually so great, the benchmark makes the difference so clear and much more accurate. Please commit the benchmark code too, would love to read and incorporate that too. |
SGCODEX
left a comment
There was a problem hiding this comment.
Please do the above. Thank you.
|
Heyy @SGCODEX I have commited the benchmark code too . |
SGCODEX
left a comment
There was a problem hiding this comment.
Heyy @vanixyz, That looks great, well done really!! Just a small change.
Please copy /code/ui_interfaces/app_local_streamlit.py file in /code/new_models/ directory and make the benchmark changes there and rename that file as app_local_streamlit_with_benchmark.py. Please revert back the changes made to /code/ui_interfaces/app_local_streamlit.py. The new_model_1 file looks great, no changes required in that right now. Thank you and really great work!!👏👏
|
Thankyou @SGCODEX I have done the required changes please review them |
There was a problem hiding this comment.
Heyy @vanixyz, can you try syncing fork once and there are still changes in the original /code/ui_interfaces/app_local_streamlit.py file, please revert it back to the original code. It will cause issues during merging. Thank you. Rest looks good.
And sorry for so many changes, also please rename code/new_models/app_local_streamlit_new_model_1.py as code/new_models/app_local_streamlit_deepface.py
Thank you so much
Ignore: #2
|
Hiii @SGCODEX I am sorry i missed that could you |
|
Hey @SGCODEX thankyou for being so cooperative , I hope it works well now 😊 |
There was a problem hiding this comment.
Heyy @vanixyz , Really commendable work!! It's superfast and way more accurate. I tried running it on my system and found some version errors, but here are the fixes for those, please comment these versions at the top of the file for other contributors to know as well.
# protobuf==3.20.3, tensorflow==2.10
Also can you add bounding box and emotion detected on the live cam feed too?
Rest looks amazing. Thanks.
Ignore #2
- Enhanced detect_emotion() to draw bounding boxes and emotion labels above detected faces - Added required version comments (protobuf==3.20.3, tensorflow==2.10) at top of the file - Verified functionality: app detects emotions, shows bounding boxes and plays emotion-based YouTube music - Prepared for merge from vanixyz:contribution to SGCODEX:contribution
|
hey @SGCODEX I have Added version requirement notes at top (protobuf==3.20.3, tensorflow==2.10) Verified live detection works with visual feedback and emotion-based music selection Ready to merge into SGCODEX:contribution. Let me know if anything else is needed. 👍 |
|
hey @SGCODEX kindly review it once . |
|
hey @SGCODEX its been a while you haven't approved it kindly do it please GSSOC'25 contributor |


📂 What I’ve Done:
✅ Created a new version of the Streamlit app as requested:
• Copied from: /code/ui_interfaces/app_local_streamlit.py
• New file: /code/new_models/app_local_streamlit_new_model_1.py
✅ Integrated DeepFace for facial emotion recognition.
✅ Used detected emotion to stream relevant music via YouTube.
✅ Improved UI with dynamic themes and emotion-based color feedback..
📌 About the Model:
I am using DeepFace’s built-in pre-trained model (Mini-Xception on FER2013) via DeepFace.analyze() with actions=["emotion"].
❗ No .hdf5 file was added manually — DeepFace manages this internally.
➕ If needed, I can place a placeholder README in /code/model/ to clarify.
Comparison: DeepFace vs. .hdf Model File Approach
✅ Ease of Use
.hdf: Requires manual loading using load_model(), manual image preprocessing, and inference.
DeepFace: One-liner functions like DeepFace.verify() and DeepFace.analyze() handle everything internally.
✅ Model Format & Flexibility
.hdf: Typically tied to a single custom model you maintain.
DeepFace: Offers multiple built-in models — VGG-Face, Facenet, ArcFace, SFace, Dlib, etc.
✅ Integration & Maintenance
.hdf: You need to write and manage the entire inference pipeline.
DeepFace: Abstracted APIs, prebuilt pipelines, and maintained by the open-source community.
✅ Performance
.hdf: Performance depends on how optimized your custom model is.
DeepFace: Optimized and tested across backends (TensorFlow, PyTorch), with consistently good speed and accuracy.
✅ Preprocessing & Utilities
.hdf: You must write preprocessing steps (resizing, normalization, alignment, etc.).
DeepFace: Automatically handles preprocessing, detection, and alignment.
✅ Deployment
.hdf: May require larger files and more setup.
DeepFace: Lightweight, self-contained, and easier to deploy for many use cases.
🧪 How to Test:
Activate environment
venv\Scripts\activate
Run the app
streamlit run code/new_models/app_local_streamlit_new_model_1.py
🔧 Dependencies:
Make sure these packages are installed:
pip install deepface opencv-python streamlit requests
Here’s a quick screenshot of the updated app in action with DeepFace integration:
🎯 Detected Emotion: happy
🎵 Now Playing: YouTube music based on emotion
📊 Benchmark Comparison Summary
Model Inference Time Detected Emotion Accuracy Observation
DeepFace 0.587s Happy ✅ Correct Detection
HDF5 Model 0.716s Fear ❌ Incorrect (User was smiling)
📝 The HDF5 model misclassified a clearly happy emotion as fear, whereas DeepFace correctly detected the expression.
🔍 Despite DeepFace being slightly faster in this test, its key strength is improved accuracy and real-time capability backed by more robust pre-trained weights and face analysis logic.
Thanks for the opportunity to contribute! 😊