- Introduction📌
- Technology Used🚀
- Dataset Used📊
- Getting Started💥
- Model Architecture⭐
- Image Processing and Training📈
- Current condition✨
- Project Components📊
- Issue🤔
- Further Works💫
- Contributing Guidelines📑
- Code Of Conduct📑
- Project Admin⚡
- Contributing is fun🧡
A Music Recommendation System Project using Flask web app that recommends music based on our facial expressions using FER-2013 Dataset and Spotify API.
- Song recommendations using Real time expression detection.
- Song Playlists is fetched from Spotify using API.
- A simple Neumorphism UI for website.
- Keras
- Tensorflow
- Spotipy
- Flask
- Tkinter (For testing)
The dataset used for this project is the famous FER2013 dataset by Kaggle. Models trained on this dataset can classify 7 emotions. The dataset can be found here.
The emotion categories includes:
- 0 = Angry
- 1 = Disgust
- 2 = Fear
- 3 = Happy
- 4 = Sad
- 5 = Surprise
- 6 = Neutral
It should be noted that the dataset is highly imbalanced with happy class having maxiumum representation. This might be a factor resulting in okayish accuracy after training the data.
- Fork this Repository.
- Clone the forked repository in your local system.
git clone https://github.com/<your-github-username>/Music-Recommendation-System.git
- Open the project folder in any local editor like Visual Studio Code.
- Run
pip install -r requirements.txt
to install all the dependencies. - In the file Spotipy.py, Enter your credentials generated by your Spotify Developer account in 'auth_manager'.
Note:-
This is only required if you want to update your recommendation playlists. Also uncomment import statement incamera.py
. - Run the main file
app.py
and give the camera permission if asked to detect the real time expressions.
- Raise an issue if you find a bug or add a feature.
- Wait for the issue to be assigned and proceed only after the issue is assigned to you.
- Navigate to the project directory.
cd Click-The-Edible-Game
- Create a new branch for your feature.
git checkout -b <your_branch_name>
- Perfom your desired changes to the code base.
- Track and stage your changes.
# Track the changes
git status
# Add changes to Index
git add .
- Commit your changes.
git commit -m "your_commit_message"
- Push your committed changes to the remote repo.
git push origin <your_branch_name>
- Go to your forked repository on GitHub and click on
Compare & pull request
. - Add an appropriate title and description to your pull request explaining your changes and efforts done.
- Click on
Create pull request
. - Congrats! 🥳 You've made your first pull request to this project repo.
- Wait for your pull request to be reviewed and if required suggestions would be provided to improve it.
- Celebrate 🥳 your success after your pull request is merged successfully.
The model architecture is a sequential model consisting of Conv2d, Maxpool2d, Dropout and Dense layers:
- Conv2D layers throughout the model have different filter size from 32 to 128.
- Pooling layers have pool size (2,2).
- Dropout is set to 0.25 as anything above results in poor performance.
- Final Dense layer has 'softmax' activation for classifying 7 emotions.
- Used 'categorical_crossentropy' for loss with 'Adam' optimizer with 'accuracy' metric.
Note:- Tried Implementing various other models like VGG16 but accuracy was far too low. This model architecture gives good enough accuracy. A bit more tinkering with hyper parameters might lead to a better accuracy.
- The images were normalised, resized to (48,48) and converted to grayscale in batches of 64 with the help of 'ImageDataGenerator' in Keras API.
- Training took around 13 hours locally for 75 epochs with an accuracy of ~66 %.
The entire project works perfectly fine. Live detection gives good frame rates due to multithreading.
- Spotipy is a module for establishing connection to and getting tracks from Spotify using Spotipy wrapper.
- haarcascade is for face detection.
- camera.py is the module for video streaming, frame capturing, prediction and recommendation which are passed to main.py.
- main.py is the main flask application file.
- index.html in 'templates' directory is the web page for the application. Basics of HTML and CSS.
- utils.py is an utility module for video streaming of web camera with threads to enable real time detection.
- train.py is the script for image processing and training the model.
The app in current state can't be deployed on web as:
- Opencv tries to open the camera on whatever device the app is running on. Code in current state makes use of webcam if available on server side not client side. So when app is run locally on a laptop Video Streaming through webcam is possible. But if it's deployed to a cloud, the app is stored in a data center somewhere which obviously doesn't have web camera connected to it and hence it doesn't work.
- Instead of CSVs, create a databse and connect it to an application. The DB will fetch songs for recommendations and new songs can be updated directly onto database.
- Add a feature which will update specified playlists for better and more recent recommendations, a specific day over a fixed duration say every sunday and append it to database.
- Directly play the song or redirect to the song on Spotify when user clicks on it.
- Rewrite code such that Video Streaming is done on client side instead of server side so as it make the app deployable.
Note: Model accuracy is not that great. It is ~66%. Further training and finetuning required. May try Vision Transformer Model.
Read our Contributing Guidelines to learn about our development process, how to propose bugfixes and improvements, and how to build to Music-Recommendation-System.
This project and everyone participating in it is governed by the Code of Conduct. By participating, you are expected to uphold this code.
Rakesh Roshan |