Spaces:
Running
Running
File size: 2,627 Bytes
9c42577 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | ---
license: mit
title: Smilo
sdk: gradio
emoji: ๐
colorFrom: blue
colorTo: green
short_description: Real-Time Emotion Detection powered by PyTorch & OpenCV
sdk_version: 5.15.0
python_version: '3.10'
app_file: app.py
pinned: false
---
# Smilo ๐
**Real-Time Emotion Detection powered by PyTorch & OpenCV**
Smilo is a lightweight, deep learning-based application that detects and classifies 7 facial emotions (Angry ๐ , Disgust ๐, Fear ๐จ, Happy ๐, Neutral ๐, Sad ๐, Surprise ๐ฎ) in real-time. It features both a local desktop interface and a beautiful web-based interactive demo!
## ๐ Getting Started
1. **Clone the repository** and navigate into the project directory:
```bash
git clone <repository-url>
cd Smilo
```
2. **Install the required dependencies**:
```bash
pip install -r requirements.txt
```
## ๐ฎ How to Use
Smilo offers two distinct ways to interact with the emotion detection model:
### 1. Web Interface (Recommended)
Run a beautifully designed web app powered by Gradio. This interface supports uploading photos, capturing snapshots, or streaming live video directly from your webcam.
```bash
python app.py
```
*After running, click the local link (e.g. `http://127.0.0.1:XXXX`) in your terminal to open it in your browser.*
### 2. Desktop Application
Run the classic desktop script. This will instantly launch a video window using your webcam feed, drawing tracking boxes and emotion labels on detected faces.
```bash
python main.py
```
*Press `q` or click the 'X' button on the video window to quit.*
## ๐ง Model & Architecture
- **Face Detection:** Uses OpenCV's optimized Haar Cascades for rapid and highly-efficient face tracking.
- **Emotion Recognition:** A custom 3-layer Convolutional Neural Network (CNN) built with PyTorch, trained on 128x128 resolution RGB images.
- **Performance:** System logic utilizes frame-skipping and concurrent processing optimizations to ensure video feeds maintain a lag-free 30+ FPS true 'live' experience.
## ๐ ๏ธ Retraining the Model
If you wish to augment the model or train it from scratch:
1. Ensure your dataset is prepared and sorted.
2. Open and run the `Train_model.ipynb` Jupyter Notebook.
3. The notebook will automatically guide you through data loading, transformation, model training, and exporting the updated inference weights (`face_classifier.pth`).
## Notes
Ensure you have adequate lighting and a clear, frontal view of your face for the most accurate predictions!
## License
See the LICENSE file for details.""
|