An intelligent system that analyzes GIFs to detect emotions, objects, actions, and generates contextually-aware natural language captions.
SentiVue is a multimodal AI system that combines:
- Emotion Detection - Classifies 6 emotion groups using ResNet50
- Object Recognition - Multi-frame YOLO detection for robust object identification
- Action Recognition - VideoMAE-based activity detection
- Scene Understanding - Lighting analysis and content type classification
- Caption Generation - Context-aware natural language descriptions
Upload a GIF, and SentiVue generates rich, emotionally-aware captions like:
"a joyful person dancing with a dog in bright lighting"
| Feature | Technology | Details |
|---|---|---|
| Emotion Detection | ResNet50 | 6 emotion groups: positive_energetic, positive_calm, negative_intense, negative_subdued, surprise, contempt |
| Object Detection | YOLO v8 | Multi-frame voting ensures accurate detection across animation frames |
| Action Recognition | VideoMAE | Detects activities (dancing, jumping, etc.) with motion-based fallback |
| Person Counting | YOLO | Counts people in the GIF with confidence thresholds |
| Lighting Analysis | OpenCV | Classifies brightness as dim, moderate, or bright |
| Caption Generation | Template-based | Context-aware English descriptions with emotion-specific vocabulary |
- RESTful endpoints with FastAPI
- Automatic API documentation (Swagger UI)
- CORS enabled for cross-domain requests
- Error handling and validation
- Detailed metadata in responses
- Modern, responsive UI (React + Tailwind CSS)
- File upload and URL-based GIF input
- Real-time processing feedback
- Detailed result visualization
- Emotion and metadata display
- Dark theme with gradient design
Backend:
- Python 3.11+
- FastAPI (REST API framework)
- PyTorch (Deep learning)
- YOLO v8 (Object detection)
- VideoMAE (Action recognition)
- OpenCV (Image processing)
- Hugging Face Hub (Model distribution)
Frontend:
- React
- TypeScript
- Tailwind CSS (Styling)
- Vite (Build tool)
- Vercel (Deployment)
- Python 3.11 or higher
- Node.js 16+ (for frontend development)
- CUDA 11.8+ (optional, for GPU acceleration)
- Git
# Clone the repository
git clone https://github.com/Akindu27/Emotion-Based-GIF-captioning-system.git
cd Prototype_final/GIF\ captioner_v2/project/backend
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Download Models
Before proceeding with installation, you need to download the pre-trained models:
1. Download the models from this [Google Drive link](https://drive.google.com/drive/folders/1cQ8Yaxt1MhlZDCsMcELU3IoT5QeYbEWr?usp=sharing)
2. Extract and place them in the `models` directory:Emotion-Based-GIF-captioning-system/Prototype_final/GIF captioner_v2/project/backend/models
3. The models directory should contain all downloaded model files.
# Install dependencies
pip install -r requirements.txt
# Run locally (development)
python main_final.py
The backend will start at http://localhost:7860 with:
- API:
http://localhost:7860/generate(POST) - Docs:
http://localhost:7860/docs - Health:
http://localhost:7860/health
# Navigate to project root
cd Prototype_final/GIF\ captioner_v2/project
# Install dependencies
npm install
# Run development server
npm run devThe frontend will be available at http://localhost:5173
# Model repository (Hugging Face Hub)
HF_MODEL_REPO=Akindu27/sentivue-models
# Local models directory
MODELS_DIR=models
# Optional: HuggingFace token for authenticated downloads
HF_TOKEN=your_hf_token_here# Local development
VITE_API_URL=http://localhost:7860
# Production (HF Space)
VITE_API_URL=https://Akindu27-sentivue-backend.hf.spaceEndpoint: POST /generate
Request:
curl -X POST "http://localhost:7860/generate" \
-F "file=@your_gif.gif"Response:
{
"emotion": "positive_energetic",
"caption": "a joyful person dancing with a dog",
"confidence": 0.92,
"objects": ["dog", "person"],
"action": "dancing",
"content_type": "real_world",
"content_warning": null,
"person_count": 1,
"lighting": {
"brightness": 120.5,
"lighting_label": "moderate"
}
}Endpoint: GET /health
Response:
{
"status": "healthy",
"device": "cpu",
"models": {
"emotion": "loaded",
"objects": "loaded",
"action": "loaded"
},
"emotion_groups": ["contempt", "negative_intense", ...]
}Endpoint: GET /
Returns API information and available features.
- Architecture: ResNet50 (feature extractor) + 2-layer classifier
- Number of Classes: 6 emotion groups
- Input Size: 224x224 RGB
- Output: Emotion label + confidence score
- Training Data: GIFGIF dataset (grouped emotions)
- Architecture: YOLO v8 Nano
- Detection Strategy: Multi-frame voting across 8 sampled frames
- Confidence Threshold: 0.20
- Post-processing: Removes generic "person" labels, keeps specific objects
- Top Results: 2 most frequently detected objects
- Architecture: VideoMAE (vision transformer for video)
- Input: 16 evenly sampled frames
- Confidence Threshold: 0.15
- Fallback: Motion-based heuristics if confidence is low
- Outputs: Actions like dancing, jumping, moving, gesturing
# Backend health check
curl http://localhost:7860/health
# Frontend build
cd project && npm run build
# Check for TypeScript errors
npm run type-check- Linting: ESLint configured for React + TypeScript
- Formatting: Prettier (run via VS Code or
npm run format) - Type Safety: Full TypeScript coverage on frontend
- Error Handling: Try-catch blocks with logging in backend
- Create a new Space at https://huggingface.co/new-space
- Select Docker SDK
- Connect GitHub repository
- Add required secrets (HF_TOKEN optional for private models)
- Space automatically rebuilds and deploys on push
Deployed at: https://Akindu27-sentivue-backend.hf.space
- Push to GitHub repository
- Connect to Vercel at https://vercel.com/import
- Configure environment variable:
VITE_API_URL=https://Akindu27-sentivue-backend.hf.space - Vercel auto-deploys on main branch push
Deployed at: https://sentivue-olive.vercel.app/
| Issue | Solution |
|---|---|
| Models fail to download | Set HF_TOKEN environment variable |
| CORS errors | Verify backend and frontend URLs match in .env files |
| Out of memory | Use CPU mode (default) or reduce GIF size |
| Slow processing | Ensure backend is running on appropriate device |
# Check if backend is running
curl http://localhost:7860/health
# View logs (development)
python main_final.py
# Verify models are downloaded
ls -la backend/models/# Clear cache and reinstall
rm -rf node_modules package-lock.json
npm install
# Build and test locally
npm run build
npm run preview- GIF Processing: 2-5 seconds (depends on GIF size and complexity)
- Model Inference: Optimized for CPU; GPU recommended for production
- Memory Usage: ~2GB RAM for all models
- Concurrent Requests: Limited by available resources
Contributions are welcome! Areas for improvement:
- Add more emotion categories
- Improve action recognition accuracy
- Optimize model inference speed
- Add batch processing capability
- Expand caption template diversity
- Multi-language support
# Create feature branch
git checkout -b feature/your-feature
# Make changes and test
npm run dev # frontend
python main_final.py # backend
# Commit and push
git add .
git commit -m "feat: your feature description"
git push origin feature/your-feature
# Create pull requestAkindu27 - GitHub | HuggingFace Hub
Back to top | SentiVue - Emotion-Based GIF Captioning System