This repository contains a Streamlit application designed to predict facial emotions from both uploaded images and pictures taken directly with the camera. Users can either upload an existing image or use their device's camera to capture a new one, and the application will analyze the facial features to determine the displayed emotion.
The application is deployed and accessible via Railway: Face Emotion Detection App and DockerHub
![Screenshot 2024-07-01 at 4 50 02 PM](https://private-user-images.githubusercontent.com/34719109/344806138-3ea5491a-e6e1-4204-9a13-06be12afde1a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExODYxMjksIm5iZiI6MTcyMTE4NTgyOSwicGF0aCI6Ii8zNDcxOTEwOS8zNDQ4MDYxMzgtM2VhNTQ5MWEtZTZlMS00MjA0LTlhMTMtMDZiZTEyYWZkZTFhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE3VDAzMTAyOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTViM2VkZGViZDBlMzRmMGI3YzhkMDYyOGRmMWY5ZDQxMGM2OTU3ZWZhZTg3NzJlMzg4MTE5ZmZlM2JmN2YxZjQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Zh7UV2rYp0i27x04TEm-KaTN1xySonPTxbCSI_7E08k)
Take Your Own Picture: Use your camera to take a picture within the application.
Upload Images: Users can upload images directly through the Streamlit interface.
Emotion Prediction: The application analyzes the uploaded images and predicts the emotions of the faces in the images.
Interactive Interface: Built with Streamlit, the application provides an interactive and user-friendly interface.
To run the application locally using Docker, follow these steps:
1. Pull the Docker Image
docker pull ozerozdal/emotion-detection-app:latest
2. Run the Docker Container
docker run -p 8501:8501 ozerozdal/emotion-detection-app:latest
3. Access the Application
Open your web browser and go to http://localhost:8501 to access the Streamlit application.
1. Launch the Application: Open the application in your web browser.
2. Provide Access: Allow the application to access your camera, then either take a picture or upload an image by clicking the "Upload" button or dragging and dropping an image.
3. View Results: Wait for the model to process the image and display the predicted emotion.
4. Feedback: After the predictions are shown, a feedback section will also appear as shown below. We value your input. Please share your experience with us!
We store the dominant emotion, timestamp, prediction probabilities and your feedback in the PostgreSQL database as shown below.
![Screenshot 2024-07-13 at 7 09 07 PM](https://private-user-images.githubusercontent.com/34719109/348507425-b0e0c6f5-79c9-403c-9646-99796ae09949.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExODYxMjksIm5iZiI6MTcyMTE4NTgyOSwicGF0aCI6Ii8zNDcxOTEwOS8zNDg1MDc0MjUtYjBlMGM2ZjUtNzljOS00MDNjLTk2NDYtOTk3OTZhZTA5OTQ5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE3VDAzMTAyOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA3OWEwMmMyMzgzMDU3OGExODY2ZjRhM2I4MDNiNzMzYmRhNThlYjMyM2QzYTdkMTllNDg0YTdjYTY4NmMwN2QmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.vkRRPylwcBpBB9w9BPj5aYE3grAH1sEHl9t2oh06PbA)
![Screenshot 2024-07-14 at 2 31 39 PM](https://private-user-images.githubusercontent.com/34719109/348573732-bb5e741b-93d7-4599-baf9-087c622c054d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExODYxMjksIm5iZiI6MTcyMTE4NTgyOSwicGF0aCI6Ii8zNDcxOTEwOS8zNDg1NzM3MzItYmI1ZTc0MWItOTNkNy00NTk5LWJhZjktMDg3YzYyMmMwNTRkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE3VDAzMTAyOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBhODk3NGE5Nzc1MTY4NGEyNTg5YTUzMmRhMzYxYWFjODM3YTRkNmQ4OTU2MGMxNjY1OTgyNjAwNzI4NjI1MDImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.BLFEjGByO-PvefslUr5N8ilMy1k2tAuOH9NGh0I4Zfg)
If you would like to configure your own PostgreSQL database, follow these steps:
-
Create Your PostgreSQL Database
- Set up a PostgreSQL database.
- Create a table with the following columns:
dominant_emotion
(type: STRING)timestamp
(type: STRING)prediction_probabilities
(type: JSON)feedback
(type: JSON)
-
Configure Your Environment
- Create a
.env
file. - Add the following line to the
.env
file:CONNECTION_URL=your_postgres_url_address
- Replace
your_postgres_url_address
with the actual URL of your PostgreSQL database.
- Create a
-
Copy .env File into Docker Container
- Use the Docker copy command to copy the
.env
file into your Docker container:docker cp path/to/your/.env your_container_name:/path/inside/container/.env
- Use the Docker copy command to copy the
-
Run Your Application
- Start your Docker container if it isn't already running.
- Your application should now be configured to use your PostgreSQL database.