Spaces:
Configuration error
Configuration error
Delete readme_md.txt
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294---title: CineAI โ Free AI Video Assistantemoji: ๐ฌcolorFrom: purplecolorTo: bluesdk: gradiosdk_version: 4.44.0app_file: app.pypinned: truelicense: mithardware: cpu-upgradesuggested_hardware: t4-smallshort_description: Upload any movie/video โ AI explains scenes, chats in Hindi, speaks responsestags: - video-understanding - hindi - movie - chatbot - multimodal - whisper - blip2 - phi3 - tts - faiss---
# ๐ฌ CineAI โ Free AI Video Assistant
> Upload any movie or video. AI understands it completely โ scenes, dialogue, characters, emotions. Chat about it in English or Hindi. Get voice responses.
---
## โจ Features
| Feature | Details ||---------|---------|| ๐ค Speech Recognition | faster-whisper (tiny/base/small, auto-selected) || ๐๏ธ Vision Understanding | BLIP-2 or BLIP-base scene captioning || ๐ฌ Chat AI | Phi-3-mini or TinyLlama instruct || ๐ฎ๐ณ Hindi Translation | NLLB-200-distilled-600M (200 languages) || ๐ Voice Output | Coqui TTS (English + multilingual) || ๐ง Memory | FAISS vector store + semantic retrieval || ๐ Web Search | DuckDuckGo (no API key) || ๐ Privacy | Session-scoped temp storage, auto-deleted |
---
## ๐๏ธ Architecture
```User uploads video โ โผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ VideoProcessor โโ โข FFmpeg: extract audio + frames โโ โข Adaptive sampling (3-10 fps) โโ โข Scene-change detection โโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโ โ โ โผ โผโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโ SpeechToText โ โ VisionAnalyzer โโ faster-whisperโ โ BLIP-2 captions โโ timestamped โ โ per frame โโโโโโโโโโฌโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโโ โ โ โโโโโโโโโโโโฌโโโโโโโโโโโ โผ โโโโโโโโโโโโโโโโโโโ โ MemoryStore โ โ FAISS + SBERT โ โ embeddings โ โโโโโโโโโโฌโโโโโโโโโ โ โโโโโโโโโโผโโโโโโโโโ โ CineAIChatbot โโโโ WebSearcher (DDG) โ Phi-3-mini โ โ streaming โ โโโโโโโโโโฌโโโโโโโโโ โ โโโโโโโโโโผโโโโโโโโโ โโโโโโโโโโโโโโโโ โ Translator โ โ TTSEngine โ โ NLLB-600M โ โ Coqui TTS โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ```
---
## ๐ Quick Start โ Local
### Prerequisites- Python 3.10+- FFmpeg installed (`sudo apt install ffmpeg` / `brew install ffmpeg`)- 16 GB RAM recommended
### Installation
```bash# Clone the repogit clone https://huggingface.co/spaces/YOUR_USERNAME/cineaicd cineai
# Create virtual environmentpython -m venv venvsource venv/bin/activate # Windows: venv\Scripts\activate
# Install dependenciespip install --upgrade pippip install -r requirements.txt
# Runpython app.py```
Open `http://localhost:7860` in your browser.
### GPU Support (optional)
If you have an NVIDIA GPU with CUDA 12.x:
```bashpip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121pip install bitsandbytes # for 4-bit quantization```
Models will automatically use GPU when available.
---
## ๐ค Hugging Face Spaces Deployment
### Method 1: Direct Upload (Recommended)
1. Go to [huggingface.co/new-space](https://huggingface.co/new-space)2. Choose: - **SDK**: Gradio - **Hardware**: CPU Upgrade (free) or T4 Small (GPU, faster)3. Upload all project files4. Space auto-builds and deploys
### Method 2: Git Push
```bash# Install HF CLIpip install huggingface_hub
# Loginhuggingface-cli login
# Create spacehuggingface-cli repo create cineai --type space --space-sdk gradio
# Pushgit initgit remote add origin https://huggingface.co/spaces/YOUR_USERNAME/cineaigit add .git commit -m "Initial CineAI deployment"git push origin main```
### Method 3: Docker (Self-hosted)
```bashdocker build -t cineai .docker run -p 7860:7860 --memory=16g cineai```
---
## ๐ง Model Download Sizes
All models are downloaded automatically on first run and cached:
| Model | Size | Use ||-------|------|-----|| faster-whisper-base | ~150 MB | Speech recognition || BLIP-2-opt-2.7b | ~5.5 GB | Scene understanding || Phi-3-mini-4k-instruct | ~7.6 GB | Chat AI || NLLB-200-distilled-600M | ~1.2 GB | Hindi translation || all-MiniLM-L6-v2 | ~22 MB | Memory embeddings || Coqui TTS | ~100 MB | Voice output |
**Total first-run download: ~15 GB** (cached for subsequent runs)
> On HF Spaces with persistent storage, models cache between restarts.
---
## โ๏ธ RAM Optimization Tips
### For 16 GB RAM (HF Free Tier):```whisper: tiny (39M params) โ 150 MBBLIP: blip-base โ 500 MB (not blip2)LLM: TinyLlama-1.1B โ 2 GBNLLB: 600M distilled โ 1.2 GBFAISS + embeddings โ 300 MBGradio + Python overhead โ 1 GBโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโTotal: โ 5 GB โ comfortably fits```
### For 16-18 GB RAM (HF CPU Upgrade):```whisper: base โ 300 MBBLIP-2: opt-2.7b โ 6 GBLLM: Phi-3-mini (4-bit GPU) โ 4 GBNLLB: 600M โ 1.2 GBFAISS โ 300 MBโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโTotal: โ 12 GB โ fits with buffer```
### Environment Variables for Tuning:
```bash# Reduce session TTL (clean up faster)export SESSION_TTL_MINUTES=30
# Limit CPU threadsexport OMP_NUM_THREADS=2export MKL_NUM_THREADS=2
# Custom temp directoryexport CINEAI_TEMP_DIR=/tmp/cineai```
---
## ๐ Privacy & Security
- โ
No user accounts or login required- โ
Videos stored in isolated `/tmp/cineai/<uuid>/` directories- โ
Automatic deletion after session timeout (default: 60 min)- โ
Background GC sweeps every 5 minutes- โ
Manual "Delete All Session Data" button in UI- โ
No analytics, no tracking, no external data sharing- โ
Session IDs are random UUIDs (unguessable)- โ
All processing happens locally on HF servers- โ
No OpenAI, Google, or any paid API calls
---
## ๐ Project Structure
```cineai/โโโ app.py # Gradio UI + event wiringโโโ requirements.txtโโโ Dockerfileโโโ README.mdโโโ core/โ โโโ __init__.pyโ โโโ video_processor.py # FFmpeg pipelineโ โโโ speech_to_text.py # Whisper ASRโ โโโ vision_analyzer.py # BLIP-2 scene analysisโ โโโ translator.py # NLLB Hindi translationโ โโโ chatbot.py # Phi-3 LLM + streamingโ โโโ memory.py # FAISS vector memoryโ โโโ web_search.py # DuckDuckGo searchโ โโโ tts_engine.py # Coqui TTSโโโ utils/ โโโ __init__.py โโโ utils.py # Helpers + monitoring โโโ session_manager.py # Privacy + auto-delete```
---
## ๐ฏ Example Questions You Can Ask
```"What happened in this movie?""Who is the main villain and what are his motivations?""Explain the ending โ what does it mean?""Translate the dialogue from minute 20 to 30 to Hindi""What's the IMDb rating of this movie?""Summarize the last 10 minutes""What are the hidden themes and symbolism?""Who plays the lead actor?""Explain the twist scene""What was the emotional climax?"```
---
## ๐ License
MIT License โ Free to use, modify, and deploy.
---
*Built with โค๏ธ using Hugging Face Transformers, Gradio, faster-whisper, BLIP-2, Phi-3, NLLB, Coqui TTS, and FAISS.*readme_md.txtDeleted-294