Minimal deployment of InternVideo2-6B with WebSocket for real-time video Q&A.
bash install.shOr manually:
pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu118
pip3 install -r requirements.txtbash run.shOr directly:
python3 app.pyNavigate to http://localhost:8000
- Open http://localhost:8000 in your browser
- Upload a video file
- Ask questions in the chat interface
- Get real-time answers
python3 test_client.pyimport asyncio
import websockets
import json
async def ask_question():
# First upload video via HTTP POST to /upload
# Get video_id from response
# Connect to WebSocket
uri = f"ws://localhost:8000/ws/{video_id}"
async with websockets.connect(uri) as ws:
# Send question
await ws.send(json.dumps({"question": "What is in this video?"}))
# Get answer
response = await ws.recv()
data = json.loads(response)
print(f"Answer: {data['answer']}")
print(f"Confidence: {data['confidence']}")
asyncio.run(ask_question())- ✅ Simple single-file deployment
- ✅ Real-time WebSocket Q&A
- ✅ Web interface included
- ✅ No Docker required
- ✅ Minimal dependencies
- ✅ GPU optimized (80GB VRAM)
| Endpoint | Method | Description |
|---|---|---|
| / | GET | Web interface |
| /upload | POST | Upload video |
| /ws/{video_id} | WS | WebSocket Q&A |
| /health | GET | Health check |
Q: What is happening in this video?
A: The person is walking
(Confidence: 92.3%)
Q: How many people are there?
A: Two
(Confidence: 87.5%)
Q: Where does this take place?
A: Indoors
(Confidence: 95.1%)
Edit these variables in app.py:
DEVICE = "cuda" # or "cpu"
MODEL_NAME = "OpenGVLab/InternVideo2-Stage2_6B"
TEMP_DIR = Path("./temp_videos")- Python 3.8+
- CUDA 11.7+ (for GPU)
- 30-40GB GPU memory for 6B model
- 16GB RAM minimum
- CUDA not found: Install NVIDIA drivers and CUDA toolkit
- Out of memory: Model requires ~30GB VRAM
- Import errors: Run
pip3 install -r requirements.txt - Port in use: Change port in
app.pylast line
- Videos are temporarily stored in
temp_videos/ - Cached features improve response time
- WebSocket maintains persistent connection
- Supports MP4, AVI, MOV, MKV formats
Check server status: http://localhost:8000/health
{
"status": "healthy",
"device": "cuda",
"model_loaded": true,
"videos_cached": 2
}