This serverless web application uses TensorFlow.js and Haar Cascade to track facial gestures and recognize dominant emotions in real-time, directly in the browser without requiring a backend server.
- Real-time face tracking using Haar Cascade
- Dominant emotion recognition
- Serverless architecture - runs entirely in the browser
- Easy deployment on platforms like Vercel
- HTML5
- CSS3
- JavaScript
- TensorFlow.js
- Haar Cascade (haarcascade.xml)
- http-server (for local development)
- FastAPI
index.html
: Main HTML file (includes embedded CSS and JavaScript)haarcascade.xml
: Haar Cascade file for face detectionmodels/
: Directory containing TensorFlow.js model files
- Clone the repository: git clone https://github.com/manish-9245/emotion-recognition.git
- Navigate to the project directory: cd face-emotion-recognition
- Install http-server globally: npm install http-server -g
- Start the local server:
npm run
5. Open your browser and navigate to
http://localhost:8080
(or the port shown in your terminal).
- Sign up for a Vercel account at https://vercel.com if you haven't already.
- Install the Vercel CLI:
npm i -g vercel
- From your project directory, run:
vercel
- Follow the prompts to link your project to Vercel.
- Your app will be deployed and you'll receive a URL for the live version.
- Open the application in a web browser.
- Allow camera access when prompted.
- Position your face in view of the camera.
- The app will track your facial gestures and display the dominant emotion detected.
- Haar Cascade classifier detects faces in the video stream.
- Detected face regions are passed to a TensorFlow.js model.
- The model analyzes facial features and predicts the dominant emotion.
- Results are displayed in real-time on the webpage.
- Performance may vary based on the user's device capabilities.
- Use a device with a good camera and a modern web browser for optimal results.
- All processing is done locally in the user's browser.
- No video or image data is sent to any server.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
- TensorFlow.js team
- OpenCV for Haar Cascade classifier
- Vercel for serverless deployment platform
- Ensure camera permissions are granted in your browser.
- Check internet connection for model loading issues.
- Use http-server for local development to avoid CORS issues.
- Support for multiple face tracking
- More detailed emotion analysis
- Mobile device optimization
For questions or issues, please open an issue on the GitHub repository.